ZF-11873: htmlspecialchars() expects parameter 1 to be string, array given
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 :
<?php class Application_Form_Public_Test_Test extends Zend_Form { public function __construct($params = null) { parent::__construct($params); $this->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 :
<?php class TestController extends Zend_Controller_Action { public function init() { } public function indexAction() { $form = new Application_Form_Public_Test_Test(); if($this->getRequest()->isPost()) { if($form->isValid($this->getRequest()->getPost())) { $arr_valeurs = $form->getValues(); } } $this->view->form = $form; $form = null; } } ?>View :
Test
<?php echo $this->form; ?>=======================================
Posted by Thibaut G. (ficoba) on 2011-11-08T19:12:00.000+0000
Details :
Form :
<?php class Application_Form_Public_Test_Test extends Zend_Form { public function __construct($params = null) { parent::__construct($params); $this->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 :
<?php class TestController extends Zend_Controller_Action { public function init() { } public function indexAction() { $form = new Application_Form_Public_Test_Test(); if($this->getRequest()->isPost()) { if($form->isValid($this->getRequest()->getPost())) { $arr_valeurs = $form->getValues(); } } $this->view->form = $form; $form = null; } } ?>View :
Test
<?php echo $this->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.