ZF-2735: Sending array to populate() sets all elements to null that aren't in array
Description
[development]
; general form metainformation
user.settings.action = "/user/settings"
user.settings.method = "post"
;formname element
user.settings.elements.formname.type = "hidden"
user.settings.elements.formname.options.value = "user_settings"
; username element
user.settings.elements.username.type = "text"
user.settings.elements.username.options.validators.alnum.validator = "alnum"
user.settings.elements.username.options.validators.regex.validator = "regex"
user.settings.elements.username.options.validators.regex.options.pattern = "/^[a-z]/i"
user.settings.elements.username.options.validators.strlen.validator = "StringLength"
user.settings.elements.username.options.validators.strlen.options.min = "6"
user.settings.elements.username.options.validators.strlen.options.max = "20"
user.settings.elements.username.options.required = true
user.settings.elements.username.options.filters.lower.filter = "StringToLower"
; password element
user.settings.elements.password.type = "password"
user.settings.elements.password.options.validators.strlen.validator = "StringLength"
user.settings.elements.password.options.validators.strlen.options.min = "6"
user.settings.elements.password.options.required = true
; submit element
user.settings.elements.submit.type = "submit"
$config = new Zend_Config_Ini('/path/to/config.ini', 'development')
$form = new Zend_Form($config);
$user_settings = array('username' => 'johndoe');
$form->populate($user_settings)
$this->view->login_form = $form;
The above would set to null all fields except username, including the hidden field which might be used in this example to figure out how to process the form.
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-05T10:24:19.000+0000
Scheduling for 1.5.0 GA release.
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-07T11:54:59.000+0000
Resolved in trunk and 1.5 release branch.
Posted by Ken Crane (kcrane377) on 2008-03-07T12:35:32.000+0000
I am still experiencing the issue with Form Images
When I populate a form my image src attrib is being set to null
Code below: [code] $image = new Zend_Form_Element_Image('submitImage'); $image->setLabel('') ->setValue('test.gif') ->setAttrib('class', 'button'); $form->addElement($image); [code] Outputs:
[code]
if ($this->_request->isPost()) { if ($form->isValid($this->_request->getPost())) { } else { $form->populate($this->_request->getPost()); } } [code] Outputs:
Posted by Ken Crane (kcrane377) on 2008-03-07T12:37:44.000+0000
Sorry about the formatting.
Here is the correct formatting:
I am still experiencing the issue with Form Images
When I populate a form my image src attrib is being set to null
Code below:
Outputs:
Outputs:
Posted by Matthew Weier O'Phinney (matthew) on 2008-03-07T12:50:04.000+0000
Ken -- what you are reporting is an unrelated issue that's specific to the image element and its decorators. I think I know what's happening, but please open a separate issue to report it.