Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Validation Error Messages
  • 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
  • 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.
  • 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.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion