Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-06-2008, 02:08 AM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Default Zend_Filter_Input presence

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:

PHP Code:
$validators = array(
    
'first_name' => array(
        
'presence' => 'required'
    
)
);


$input = new Zend_Filter_Input(null$validators$data); 
If the field is missing the error message I get is:
"Field 'first_name' is required by rule 'first_name', but the field is missing"
I would like to display:
"Field 'First Name' is required."
Thanks for any help,

Brian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-06-2008, 04:58 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

I wrote custom validation routines that allow me to use Zend's validators, but not in an automatic manner. This gave me the most flexibility.

You could possibly change the message before it gets printed to the screen, by checking for first_name in the output, and triggering a different message based on it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-06-2008, 05:01 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

Also, you should take a look at the messages metacommand, as explained here:
Zend Framework: Documentation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:24 AM.