Forum OpenACS Q&A: ad_form and checkbox

Collapse
Posted by Antonio Laterza on
Hi all, I'm tryng to use ad_form in a section where I want do a backup of tables on one package. The first step is to show all tables and tables fields in order to allow a selection of field to backup....

So I show all the table and all the fields using ad_form:

<pre>
set all_candidate_tables {table1, table2, table3}
foreach i $all_candidate_tables {
    set cols [db_columns $i]
    set opts ""
    foreach n $cols {
    lappend opts "$n $n"
    }
    lappend all_candidate_tables2 [list $i:text(checkbox),multiple,optional {} [list options $opts ]]
}
ad_form -name lista -form $all_candidate_tables2
....
</pre>

The code gives for each field of tables a code like:

<td> <input type="checkbox" name="table1" value="field1_of_table1" id="lista:elements:table1:field1"  /> </td>

And it's ok. But I want all field selected by default. So my question is how can I obtain a code where each field is checked? like:

<td> <input type="checkbox" name="table1" value="field1_of_table1" id="lista:elements:table1:field1"  checked /> </td>

thx

Collapse
2: Re: ad_form and checkbox (response to 1)
Posted by Andrei Popov on
...add html {checked checked} in lappend?
Collapse
3: Re: ad_form and checkbox (response to 2)
Posted by Antonio Laterza on
ok! works fine.
Changed in

lappend all_candidate_tables2 [list $i:text(checkbox),multiple,optional {} [list options $opts ] [list  html {checked checked}]]

Results:

<td> <input type="checkbox" name="table1" value="field1_of_table1" id="lista:elements:table1:field1"  checked checked="checked" /> </td>

Many thanks Andrei