I'm still having trouble with this.  I can set error messages for individual
validators that I use, like the documentation describes:

<?php
$validators = array(
    'month' => array(
        'digits',
        'messages' => 'A month must consist only of digits'
    )
);

However, I'm unable to do this for the metacommands  'precence'.   When I
change the code above to check for presence and try to supply an error
message: 

<?php
$validators = array(
    'month' => array(
        'digits',
                'presence' => 'required',
        'messages' => array('A month must consist only of digits',
                                array('missingMessage' => "A value is required 
for field 'Month'"))
    )
);

I get the error message: Fatal error: Uncaught exception
'Zend_Validate_Exception' with message 'No message template exists for key
'missingMessage'' in library\Zend\Validate\Abstract.php:129

I am able to set and error message globally for the 'presence' metacommand
using:

<?php
$options = array(
    'missingMessage' => "A value is required for field '%field%'"
);

$input = new Zend_Filter_Input($filters, $validators, $data, $options);


But this doesn't allow me to put a user presentable field name into the
message.

Brian



SiCo007 wrote:
> 
> Brian you need to take a look at the message system that accompanies the
> filter_input
> 
> http://framework.zend.com/manual/en/zend.filter.input.html#zend.filter.input.metacommands.messages
> 
> Then it's just a case of specifying the correct message for the correct
> action. Sometimes you will need to look in the validator to check what
> messages it sets up.
> 
> Simon
> 
> 
> brian3f wrote:
>> 
>> I'm using Zend_Filter_Input to validate form data.  I'm trying to use the
>> 'presence' => 'required', metacommand.  My problem is, the error message
>> generated by this command includes the actual field name that is being
>> checked.  my field name is something 'first_name' but I want to display
>> 'First Name'.  Here is some pseodo code representing what I'm doing.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Filter_Input-%27presence%27%3D%3E%27required%27-tp15865637s16154p15877121.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to