Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to localize Orm\\Observer_Validation messages?
  • I added validation rules to my Model _properties and add Orm\\Observer_Validation at the 'before_save' event. It works good, but I don't know, how to change languge of its error messages?

    Earlier, I used Validation::set_message() for this purposes, before I decided to use Orm Validation.

    What is the better way to do this?

    Thank you.
  • And one more question.
    May I call Orm Validation not by observer, but by manual call... something like that:

    $post = Model_Post::forge();
    $val = $post->get_validations();

    if ($val->run()) {
    ...
    }

    It is the porblem to need make some changes to data after validation, not before... So, I need make one more Observer for it and add to model...

    Different changes bring me to create for every model it's own observer for this changes. It's so redudant work... I need validation before changes and save.
  • The second problem I solved in this way:

    $service = \Backend\Model_Service::forge();
                $fieldset = \Fieldset::forge('service')->add_model($service );
                $val = $fieldset->validation();
                if ($val->run()) {

    And what about first? I think, I need to extend Fuel\Core\Validation and set_messages in some method like _init() or forge() (don't know, need to look in source)... Or exists another way?
  • HarroHarro
    Accepted Answer
    There is a validation language file that is used by the Validation class. The enlish version is in ./fuel/core/lang/en. You can add translations like normal.

    And calling validation manually like this is absolutely fine.
  • Thank you... I have to read docs better :)

Howdy, Stranger!

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

In this Discussion