Issues

ZF-11577: htmlspecialchars() expects parameter 1 to be string, array given

Issue Type: Bug Created: 2011-07-19T08:56:31.000+0000 Last Updated: 2011-07-19T14:12:22.000+0000 Status: Resolved Fix version(s): Reporter: Goran Sumzer (sumzer) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

  • Zend_View

Related issues: Attachments:

Description

Warning: htmlspecialchars() expects parameter 1 to be string, array given in /usr/share/php/libzend-framework-php/Zend/View/Abstract.php on line 897.

this is code from form, $this->setDecorators(array( 'FormElements', array('Errors', array('placement' => 'PREPEND')), array('HtmlTag', array('tag' => 'dl', 'class' => 'login_elements')), 'Form' ));

everything is ok until array('Errors', array('placement' => 'PREPEND')) is put into setDecorators or just 'Errors' ...

Comments

Posted by Kai Uwe (kaiuwe) on 2011-07-19T10:20:33.000+0000

There's a difference if the errors messages comes from an element or from the form.

<pre class="highlight">
array(1) {
  ["isEmpty"]=>
  string(36) "Value is required and can't be empty"
}



<pre class="highlight">
array(1) {
  ["foo"]=>
  array(1) {
    ["isEmpty"]=>
    string(36) "Value is required and can't be empty"
  }
}

At the moment it is a bad idea to use the "Errors" decorator for the whole form, because there is no reference to the element or to the label of the element.

We need a solution which respects the array from the form and which outputs the label from the element.

<pre class="highlight">


Foo: Value is required and can't be empty

Posted by Matthew Weier O'Phinney (matthew) on 2011-07-19T13:35:20.000+0000

There is already a special decorator (and view helper) for displaying errors at the form level, "FormErrors"; use that instead of the "Errors" decorator.

Posted by Kai Uwe (kaiuwe) on 2011-07-19T14:12:22.000+0000

Matthew is right. Damn, I use it even in my own scripts!

Thanks to Matthew.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts