Details
Description
For each invalid field Zend_Form generates a warning:
Warning: htmlspecialchars() expects parameter 1 to be string, array given in /Library/WebServer/Library/Zend/View/Abstract.php on line 804
I've encountered this with both Select fields and normal Text fields, but other elements might be affected as well. A valid field does not generate this warning. The error messages do appear next to the elements.
Select code:
$fieldElement1 = new Zend_Form_Element_Select('field1'); $fieldElement1->setRequired(true) ->setAllowEmpty(false) ->setMultiOptions(array('foo' => 'FOO', 'bar' => 'BAR'));
Textfield code:
$queryElement1 = new Zend_Form_Element_Text('query1'); $queryElement1->setRequired(true) ->setAllowEmpty(false);
Edit:
The call to Zend_View_Abstract's escape() method originates from Zend_View_Helper_FormErrors line 75. A var_dump() on line 74 gives these results:
array
'isEmpty' => string 'Value is empty, but a non-empty value is required' (length=49)
array
'isEmpty' => string 'Value is empty, but a non-empty value is required' (length=49)
array
'field1' =>
array
'isEmpty' => string 'Value is empty, but a non-empty value is required' (length=49)
'query1' =>
array
'isEmpty' => string 'Value is empty, but a non-empty value is required' (length=49)
Edit2:
It appears it's caused by adding the Errors decorator manually with $this->addDecorator('Errors');
Issue Links
| This issue is duplicated by: | ||||
| ZF-9002 | Warning on form validation |
|
|
|
I'm actually unsure exactly what the issue is. I've tried creating the elements you specify, passing invalid values to isValid(), and rendering, but with no errors. I've even tried specifying adding the Errors decorator manually – I simply cannot reproduce any sort of warning.
I'm going to mark the issue as "cannot reproduce". Feel free to re-open if you can provide the following, succinctly: