zend framework - Zend_Form not showing error message -
i have following zf form element.
$this->addelement('text', 'price', array( 'required' => true, 'label' => 'price:', 'attribs' => array( 'title' => 'please enter value of artwork'), 'filters' => array('currency'), 'validators' => array( array('notempty', true, array( 'messages' => array( zend_validate_notempty::is_empty => "you must enter artworks price"))), array('float', true, array( 'messages' => array( zend_validate_float::invalid => "you must enter valid price", zend_validate_float::not_float => "you must enter valid price"))), array('greaterthan', true, array( 'min' => 0.99, 'messages' => array( zend_validate_greaterthan::not_greater => "you must enter value of £1.00 or more")))) )); the last validator zend_validate_greaterthan has been set error message, problem error message not displayed on form when validator fails. rendered empty unordered list!!
<ul> <li></li> </ul> when check messages output zend_form error , message.
array(1) { ["price"]=> array(1) { ["notgreaterthan"]=> string(39) "you must enter value of £1.00 or more" } } does know why message not being rendered on form?
many in advance
garry
edit
the decorator using viewscript render form, on form have.
$this->setdecorators(array( array('viewscript', array('viewscript' => 'forms/add-item.phtml')) )); and viewscript itself.
$attribfilterobj = new freedom_zend_filter_htmlattribs(); $attribs = $attribfilterobj->filter($this->element->getattribs()); ?> <form <?php echo $attribs; ?>> <dl> <?php echo $this->element->artworktitle->title->render(); ?> <?php echo $this->element->artworkdescription->description->render(); ?> <?php echo $this->element->price->render(); ?> <?php echo $this->element->genres->render(); ?> <?php echo $this->element->image->render(); ?> <?php echo $this->element->add->render(); ?> </dl> </form> edit
the output of var_dump follows
array(5) { ["zend_form_decorator_viewhelper"]=> object(zend_form_decorator_viewhelper)#157 (6) { ["_buttontypes":protected]=> array(3) { [0]=> string(24) "zend_form_element_button" [1]=> string(23) "zend_form_element_reset" [2]=> string(24) "zend_form_element_submit" } ["_helper":protected]=> null ["_placement":protected]=> string(6) "append" ["_element":protected]=> null ["_options":protected]=> array(0) { } ["_separator":protected]=> string(2) " " } ["zend_form_decorator_errors"]=> object(zend_form_decorator_errors)#158 (4) { ["_placement":protected]=> string(6) "append" ["_element":protected]=> null ["_options":protected]=> array(0) { } ["_separator":protected]=> string(2) " " } ["zend_form_decorator_description"]=> object(zend_form_decorator_description)#159 (6) { ["_escape":protected]=> null ["_placement":protected]=> string(6) "append" ["_tag":protected]=> null ["_element":protected]=> null ["_options":protected]=> array(2) { ["tag"]=> string(1) "p" ["class"]=> string(11) "description" } ["_separator":protected]=> string(2) " " } ["zend_form_decorator_htmltag"]=> object(zend_form_decorator_htmltag)#160 (7) { ["_encoding":protected]=> null ["_placement":protected]=> null ["_tag":protected]=> null ["_tagfilter":protected]=> null ["_element":protected]=> null ["_options":protected]=> array(2) { ["tag"]=> string(2) "dd" ["id"]=> array(1) { ["callback"]=> array(2) { [0]=> string(22) "zend_form_element_text" [1]=> string(16) "resolveelementid" } } } ["_separator":protected]=> string(2) " " } ["zend_form_decorator_label"]=> object(zend_form_decorator_label)#161 (6) { ["_placement":protected]=> string(7) "prepend" ["_tag":protected]=> null ["_tagclass":protected]=> null ["_element":protected]=> null ["_options":protected]=> array(1) { ["tag"]=> string(2) "dt" } ["_separator":protected]=> string(2) " " } }
this caused forgetting include 'errors' in form decorator element. if you're using custom decorator, check first.
Comments
Post a Comment