Issues

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

Issue Type: Bug Created: 2011-11-06T20:37:27.000+0000 Last Updated: 2011-11-08T19:15:13.000+0000 Status: Open Fix version(s): Reporter: Thibaut G. (ficoba) Assignee: Christian Albrecht (alab) Tags: - Zend_Form

  • Zend_View

Related issues: Attachments:

Description

If a Zend_Form_Element_Text() is setRequired(true) and the setValue() is empty when the form validation. An PHP error is displayed.

Source File: Zend\View\Abstract.php : 905 Function Name: htmlspecialchars Error String: htmlspecialchars() expects parameter 1 to be string, array given Error Type: E_WARNING

Try (line 905): htmlspecialchars(array('isEmpty' => 'Value is required and can't be empty'), 2, 'UTF-8');

It's the same error with : ZF-4030 ; ZF-8112 ; ZF-8113

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2011-11-07T13:41:15.000+0000

Could you provide sample code exposing the problem? I've tried to reproduce against SVN trunk based on what you have provided, but cannot trigger the problem.

Posted by Thibaut G. (ficoba) on 2011-11-08T19:09:53.000+0000

Form :

setName('frm\_test') ->setDecorators(array('Errors', 'FormElements', 'Form'));; $test = new Zend\_Form\_Element\_Text('test'); $test->setLabel('Label :') ->setRequired(true); $validation = new Zend\_Form\_Element\_Submit('validation'); $validation->setLabel('Validation'); $this->addElements(array($test, $validation)); } } ?> - - - - - -

Controller :

getRequest()->isPost()) { if($form->isValid($this->getRequest()->getPost())) { $arr\_valeurs = $form->getValues(); } } $this->view->form = $form; $form = null; } } ?> - - - - - -

View :

Test

form; ?> =======================================

Posted by Thibaut G. (ficoba) on 2011-11-08T19:12:00.000+0000

Details :

Form :

setName('frm\_test') ->setDecorators(array('Errors', 'FormElements', 'Form'));; $test = new Zend\_Form\_Element\_Text('test'); $test->setLabel('Label :') ->setRequired(true); $validation = new Zend\_Form\_Element\_Submit('validation'); $validation->setLabel('Validation'); $this->addElements(array($test, $validation)); } } ?> - - - - - -

Controller :

getRequest()->isPost()) { if($form->isValid($this->getRequest()->getPost())) { $arr\_valeurs = $form->getValues(); } } $this->view->form = $form; $form = null; } } ?> - - - - - -

View :

Test

form; ?> =======================================

Posted by Thibaut G. (ficoba) on 2011-11-08T19:15:13.000+0000

I'm so sorry for double comment and the copy/paste my sample code PHP has not took into consideration the line break.

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