I have relations like Project hasMany Photos and the simplest validation (require attach) rule for Photo.image.
But when I add Project with one added file is ok, but when i create many input type file, and part with attached files and part without, then my rule doesn’t work good.
…because I want require minimum one file, how solution for this?
Project hasMany Photos with minimum one required…
Actually, it should be model validation, as what you are trying to do is creating a “Project has one to M Photos” relationship between the two. So this validation should be done on the beforeValidate function at the Project model:
Project Model
The rest will be handled correctly by CakePHP’s validation rules.