The problem is, int the view, if a validation fails, each field is marked red, with the error message. How, should i write my form, that the error message is only connected to the field where the validation error actually occurs?
I looked at my $docmodel after the validation error, and the error is liked to the ‘doc_url’ field. There is no distinction between the different ‘doc_url[$i]’ fields. So the error message is written for each echo $form->error($docmodel,“doc_url[$i]”); command.
You are right, i pass the same model to each field. I should create a new model insatnce for each field. So if my foreach runs lets say 5 times i sould have 5 different models $docmodel1, $docmodel2 etc…
The validation occurs, because if the field is not an url (my rule is array(‘doc_url’, ‘url’,‘allowEmpty’=>true),) the form is not submitted, but there is no error message. If i look at the $docmodel array, there is no sign of an error recorded either.