Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.6.0
-
Fix Version/s: None
-
Component/s: Zend_Form
-
Labels:None
Description
function getValues() [1.6.0RC2 - 1.6.0] [LINE: 1286]
$values = array_merge($values, $fValues);
Naming a SubForm with a numeric value results in loss of that name when calling $form->getValues();
Since the storage of Subforms uses an associative array, it seems ZF should maintain those keys regardless of type. Using array_merge() will rekey any arrays with numeric values as keys resulting in the loss of that SubForm name.
Example
$form = new Zend_Form; $form->addElement( new Zend_Form_Element_Text('username') ); $subform = new Zend_Form_SubForm(); $subform->addElement( new Zend_Form_Element_Text('subform_name') ); $form->addSubForm($subform, '12345'); // Naming it with a string that happens to be numeric $simulated_request = array('username'=>'JoeTest', '12345'=>array('subform_name'=>'FredTest') ); $form->populate($simulated_request); $form_values = $form->getValues(); echo "<pre>".print_r($form_values, true);
Result
Array
(
[username] => JoeTest
[0] => Array
(
[subform_name] => FredTest
)
)
For a variety of reasons, we decided that element, sub form, and display group names must be valid variable names. This means that numeric names are not compatible with the design. We have no plans to alter that support.