tags:

views:

25

answers:

1

How do you make validation in CakePHP stop if any single rule fails for any field?

I know about the 'last' property but that only stops validation for that field, I want it to stop completely.

Thanks.

A: 

I was validating a picture upload in the model and then uploading it there and creating a user folder for the photo. Obviously I didn't know the user ID if the record failed the photo validation so the folder couldn't be created.

I have modified my validation to validate the upload and added a reference to the temporary uploaded file within the model class. I then wrote a custom afterSave() function to check if the user had uploaded an image when they registered, and if so to create the appropriate folders and move the image to a permanent location.

Thanks for the help.

ABailiss