|
|||
|
Hi everyone,
I've been experimenting with Zend Forms lately and I encountered the same problem for the last couple of days and I can't really solve this on my own. The main idea is that I want to display my error messages in my own language. These are some lines of my Form: <?php $starttime = new Zend_Form_Element_Text('starttime'); $starttime->setLabel('Start tijd (in de vorm "YYYY-MM-DD hh:mm")') ->setRequired(true) ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Empty!'))) ->addValidator(new Zend_Validate_Date('YYYY-MM-DD hh:mm'), true, array('messages' => array(Zend_Validate_Date::FALSEFORMAT => 'Waarde is niet goeedd'))); ?> When I submit my Form, ZF validates my input, but my "starttime"-field doesn't get validated like I want to: <? array(6) { ["starttime"]=> array(1) { ["dateFalseFormat"]=> string(34) "'a' does not fit given date format" } ... and some more } ?> As you can see, my starttime errormessage is just the default errormessage "'a' does not fit given date format" (because I entered a wrong date format). I think that's strange because I defined that as "Waarde is niet goeedd". When I don't fill in anything, the validation does go as I want it to: it gives my custom errormessage "Empty!" Do you have any solutions for my problem? Am I doing something terrible wrong? Thanks a lot in advance, Arthur |
|
|||
|
you can use zend_translate ( Zend Framework: Documentation )
or you can set custom error messages ( Zend Framework: Documentation ). |
|
|||
|
Thanks for the response.
I have already seen this option, but I thought that is was possible to define these error messages in my Zend Form object as well... It does work in the isEmpty validation, but it does not work in the date validation! Seems like I'm doing something wrong or will I just have to define these messages in my Controller anyway? |
![]() |
| Thread Tools | |
| Display Modes | |
|
|