[development] $form #tree issue
Alessandro Feijó
patrao at legendas.feijo.info
Tue Jan 15 13:24:17 UTC 2008
I'm building a dynamic filter system, my user will be able to add as much criteria he wants
Here a tiny example of my current aproach:
$form['criteria'] = array(
'#type' => 'fieldset',
'#title' => t('Criterias'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
for ($i=1; $i<=variable_get('beginer_criteria', 3); $i++) {
$form['criteria'][$i]['table[]'] = array(
'#type' => 'select',
'#options' => $tables,
'#value' => $load[$i]['table'],
'#description' => $load[$i]['table'],
'#attributes' => array(
'class' => 'edit-table',
),
);
}
The form will start with X sets of fields (2 combo, 1 editfield)
I set jQuery to clone any of those criteria, adding more
Here the problem begin, any cloned, will have the same name of the original one.
My $form_values does not return the cloned fields.
my HTML is:
<div class=qz-tablefield><div class="form-item">
<select name="criteria[1][table[]]" class="form-select edit-table" id="edit-criteria-1-table[]" ><option value="0">Select an option</option><option value="6">criticality</option><option value="2">group</option><option value="4">origin</option><option value="3">position</option><option value="5">priority</option><option value="1">reason</option><option value="7">status</option></select>
</div>
<div class="form-item">
<select name="criteria[1][field[]]" class="form-select edit-field" id="edit-field1" id="edit-criteria-1-field[]" ><option value="0">Select a table</option></select>
</div>
<div class="form-item">
<input type="text" maxlength="100" name="criteria[1][value[]]" id="edit-criteria-1-value[]" size="30" value="" class="form-text" />
</div>Note the criteria[1], the next set will be criteria[2]The cloned criteria will to be 1 ! the $form_values ignore the new fields.What can I change in my $form to solve that?
Thanks a lot
Feijó
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080115/a5ca32a4/attachment.htm
More information about the development
mailing list