Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Multiple validations?
  • I'm using 1.3 stable with the ORM package.

    I have a basic REST controller to create a new, basic "message" (subject & body) that can have attachments. Message & Attachment are models, since a message has many attachments.

    In the Message model, in createMessage() method, I'm running:
    self::validate( 'create' )
    to validate the fields for Message.

    In that same method, I need to create attachments & validate them too (else cancel saving the message on failure). When I try to do Model_Attachment::validate('create') it throws an error about how validation is already instantiated.

    I used Validation::instance() which worked, but I'm not sure how it knows to validate the attachments model. It doesn't error, but I feel like this isn't the correct way to do this?
  • If you want to use the model for validation, you should look into the Validation observer. It runs automatically on save(), based on the validation rules defined in $_properties.

Howdy, Stranger!

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

In this Discussion