ivo trompert wrote:
>
> For Zend_Filter_Input() I need a custom error message because I'm dutch
> and the website I make is also dutch. I have setup validators as follows:
>
> $validators = array(
> 'name' => array('allowEmpty' => false,
> 'username' => array('Alpha','allowEmpty' => false),
> 'password1' => array('Alpha', 'allowEmpty' => true),
> 'password2' => array('allowEmpty' => true)
> );
>
> If 'name' is empty I want to show the users the following error "Voornaam
> is verplicht!" (this is dutch). I have read in the user manual the
> following code:
>
> $validators = array(
> 'month' => array(
> 'digits', new Zend_Validate_Between(1, 12),
> 'messages' => array(
> 'A month must consist only of digits',
> array(
> Zend_Validate_Between::NOT_BETWEEN =>
> 'Month value %value% must be between %min% and %max%',
> Zend_Validate_Between::NOT_BETWEEN_STRICT =>
> 'Month value %value% must be strictly between %min%
> and %max%'
> )
> )
> )
> );
>
> This is the code I need for the custom message. But when I transform the
> code to this code:
>
> 'name' => array('allowEmpty' => false, 'messages' =>
> array(Zend_Validate_NotEmpty::IS_EMPTY => 'Voornaam is verplicht!')),
> 'username' => array('Alpha','allowEmpty' => false),
> 'password1' => array('Alpha', 'allowEmpty' => true),
> 'password2' => array('allowEmpty' => true)
> );
>
> I get the standard error message:"You must give a non-empty value for
> field 'name'".
>
> My question is: How can I change this message field independent (with out
> setup a message in the option section).
>
> Thank you,
>
> Ivo Trompert
>
I found the solution but now I have a another problem with input. My new
code is this:
'name' => array('NotEmpty', 'messages' => 'Voornaam is verplicht!'),
'username' => array('NotEmtpy'),
'password1' => array('Alpha', 'allowEmpty'=> true),
'password2' => array('allowEmpty' => true)
);
But the problem now is that if I give the second field a message (the second
field is the 'username') like this:
'name' => array('NotEmpty', 'messages' => 'Voornaam is verplicht!'),
'username' => array('NotEmtpy', 'messages' => 'De
gebruikers naam is
verplicht!'),
'password1' => array('Alpha', 'allowEmpty'=> true),
'password2' => array('allowEmpty' => true)
);
I get the folowing error:
Fatal error: Uncaught exception 'Zend_Filter_Exception' with message 'Unable
to find the implementation of the 'NotEmtpy' class' in
/storage/wwwroot/Zend/Filter/Input.php:830 Stack trace: #0
/storage/wwwroot/Zend/Filter/Input.php(786):
Zend_Filter_Input->_getFilterOrValidator('Zend_Validate_I...', 'NotEmtpy')
#1 /storage/wwwroot/Zend/Filter/Input.php(628):
Zend_Filter_Input->_getValidator('NotEmtpy') #2
/storage/wwwroot/Zend/Filter/Input.php(556): Zend_Filter_Input->_validate()
#3 /storage/wwwroot/Zend/Filter/Input.php(328):
Zend_Filter_Input->_process() #4
/storage/wwwroot/app/modules/default/controllers/UsersController.php(63):
Zend_Filter_Input->isValid() #5
/storage/wwwroot/Zend/Controller/Action.php(497):
UsersController->editAction() #6
/storage/wwwroot/Zend/Controller/Dispatcher/Standard.php(237):
Zend_Controller_Action->dispatch('editAction') #7
/storage/wwwroot/Zend/Controller/Front.php(911):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http)) in
/storage/wwwroot/Zend/Filter/Input.php on line 830
There is no different error if I put the messages in a array like this:
$validators = array(
'name' => array('NotEmpty', 'messages' =>
array(Zend_Validate_NotEmpty::IS_EMPTY =>'Voornaam is verplicht!')),
'username' => array('NotEmtpy', 'messages' =>
array(Zend_Validate_NotEmpty::IS_EMPTY => 'De gebruikers naam is
verplicht!')),
'password1' => array('Alpha', 'allowEmpty'=> true),
'password2' => array('allowEmpty' => true)
);
What is wrong with this code?
thank you,
Ivo Trompert
--
View this message in context:
http://www.nabble.com/Zend_Filter_Input%28%29-tf4269740s16154.html#a12154558
Sent from the Zend Framework mailing list archive at Nabble.com.