create a repeater in a form


I’m building a form to put products into the site.

the problem is the pictures haven’t a fixed number, i mean it could be one photo for a product or 6 photo for another.

before Yii, i handled this situation with name attribute of the form, put a "[]" at the end of input name and it sends an array of results to the $_POST.

but in Yii if i do that, the rules doesn’t understand that the inputs are different from each other, if the last input has a wrongExtension error, the error will appear on all the inputs (even the ones that has right value).

What is the practice in this situations in Yii ?

  • Note that the pictures are not just a photo field, they have 3 attribute, i can’t use MultipleUpload feature.