Validation & AR transaction


I’m trying to use transaction in my controler, using this example:

But When the validation fails (for a missing field for exemple), the errorSummary is not displayed anymore.

Every indication about the validation error is missing.

If I remove the transaction, everything is back to normal.

Any idea?


You should not try to save if validation fails.

The transaction is just a safety more in case of error while saving valid models, but is better to do something like:

$valid= $model1->validate();

$valid= $model2->validate() && $valid;

$valid= $model3->validate() && $valid;

$valid= $model4->validate() && $valid;

if ($valid)


   save all with transaction!


Using this schema you will never try to save a model if they are not all valid. The question of validation result independent from the transaction.

Ok, that make sense.


I’m having a similar problem using transactions. I understand this part about how to test validation, but how do you send specific validation errors back to the form so that


will display them? Or is there another route you need to go to display them?