I probably found another bug in ZF forms, but before i submit issue i
want someone to confirm it. Problem occurs when trying to add multiple
belongsTo elements to displayGroup. After outputing form only last added
element is available inside display group.
Example code:
foreach ($minimals as $row ) {
/* @var $row Mao_Db_Table_Row */
$this->addElement(
'NumberTextBox',
'_states_min_mag_'. $row->storehouse_id,
array(
'name' => $row->storehouse_id,
'label' => 'Minimum',
'min' => 0,
'places' => 0,
'maxlength' => 20,
'belongsTo' => '_minimals',
'value' => $row->minimum,
)
);
$this->addElement(
'NumberTextBox',
'_states_max_mag_'. $row->storehouse_id,
array(
'name' => $row->storehouse_id,
'label' => 'Maximum',
'min' => 0,
'places' => 0,
'maxlength' => 20,
'belongsTo' => '_maximals',
'value' => $row->maximum,
)
);
$this->addDisplayGroup(
array(
'_states_min_mag_'. $row->storehouse_id,
'_states_max_mag_'. $row->storehouse_id,
),
'_states_dg_mag_'. $row->storehouse_id,
array(
'legend' => $row->storehouse_name,
)
);
}
And in output we can find only:
<dl class="zend_form">
<dt id="_states_dg_mag_1-label"> </dt><dd id="_states_dg_mag_1-element"><fieldset id="fieldset-_states_dg_mag_1" store_id="1"><legend>Wrocław</legend>
<dl>
<dt id="1-label"><label for="_maximals-1" class="optional">Maximum</label></dt>
<dd>
<input min="0" id="_maximals-1" name="_maximals[1]" value="" type="text"></dd></dl></fieldset></dd>
<dt id="_states_dg_mag_2-label"> </dt><dd id="_states_dg_mag_2-element"><fieldset id="fieldset-_states_dg_mag_2" store_id="2"><legend>Dublin</legend>
<dl>
<dt id="2-label"><label for="_maximals-2" class="optional">Maximum</label></dt>
<dd>
<input min="0" id="_maximals-2" name="_maximals[2]" value="500" type="text"></dd></dl></fieldset></dd>
<dt id="_states_dg_mag_3-label"> </dt><dd id="_states_dg_mag_3-element"><fieldset id="fieldset-_states_dg_mag_3" store_id="3"><legend>Cork</legend>
<dl>
<dt id="3-label"><label for="_maximals-3" class="optional">Maximum</label></dt>
<dd>
<input min="0" id="_maximals-3" name="_maximals[3]" value="" type="text"></dd></dl></fieldset></dd></dl>
Fast test:
foreach ($this->getDisplayGroups() as $dg) {
/* @var $dg Zend_Dojo_Form_DisplayGroup */
echo '<pre>'; print_r( $dg->getId() ); echo "\n";
foreach ($dg->getElements() as $element) {
/* @var $element Zend_Form_Element */
echo "\t"; print_r( $element->getId() ); echo "\n";
}
echo "\n</pre>";
}
and output:
_states_dg_mag_1
_maximals-1
_states_dg_mag_2
_maximals-2
_states_dg_mag_3
_maximals-3
Can anyone confirm that my method of constructing form and trying to
visually group elements is correct, and problem lies in ZF?
--
Best regards,
Szatanik Krzysztof.
没有评论:
发表评论