Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
Validation Error Messages
mayismile
May 2013
Is it possible to set error messages like this?
$val->add('price', 'Price')
->add_rule('required')
->add_rule('valid_string', array('numeric'))
->set_message('required', 'The :field is required')
->set_message('valid_string', 'The :field contains invalid chars');
And $val->error('price') outputs the message depending on the rule.
Thanks
Harro
May 2013
If you mean a message per rule per field, the answer is "currently not".
This is on the roadmap, but at the moment rules and their messages are stored in the validation object, and are therefore global for all fields.
mayismile
May 2013
Yes, I have meant per rule per field.
I always did it like that, but wanted to do it more easier
if($val->error('price')->rule == 'required'){
echo '....';
}
Any way, thank you for the answer.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
May 2013
mayismile
May 2013