I have a form created with CActiveForm and the HTML output is something like this
...
<tr>
<td><input class="span9" placeholder="Type in the seminar title" name="CvSeminar[0][title]" id="CvSeminar_0_title" maxlength="255" value="Some Value" type="text"> <span class="help-inline error" id="CvSeminar_0_title_em_" style="display: none"></span> </td>
<td><input class="span1" name="CvSeminar[0][yearIssued]" id="CvSeminar_0_yearIssued" maxlength="4" value="2009" type="text"> <span class="help-inline error" id="CvSeminar_0_yearIssued_em_" style="display: none"></span> </td>
<td><a href="#" class="removeSeminarRow"><i style="margin-top: 10px" class="icon-remove"></i></a></td>
</tr>
<tr>
<td><input class="span9" placeholder="Type in the seminar title" name="CvSeminar[1][title]" id="CvSeminar_1_title" maxlength="255" value="Some Value" type="text"> <span class="help-inline error" id="CvSeminar_1_title_em_" style="display: none"></span> </td>
<td><input class="span1" name="CvSeminar[1][yearIssued]" id="CvSeminar_1_yearIssued" maxlength="4" value="2006" type="text"> <span class="help-inline error" id="CvSeminar_1_yearIssued_em_" style="display: none"></span> </td>
<td><a href="#" class="removeSeminarRow"><i style="margin-top: 10px" class="icon-remove"></i></a></td>
</tr>
...
As you can see i create an area where each row cantains two fields. I have also created a button where a user can add a new row. The html output when the user hits the button is:
<tr>
<td><input class="span9" placeholder="Type in the seminar title" name="CvSeminar[1000][title]" id="CvSeminar_1000_title" maxlength="255" type="text"><span class="help-inline error" id="CvSeminar_1000_title_em_" style="display: none"></span></td>
<td><input class="span1" name="CvSeminar[1000][yearIssued]" id="CvSeminar_1000_yearIssued" maxlength="4" type="text"><span class="help-inline error" id="CvSeminar_1000_yearIssued_em_" style="display: none"></span></td>
<td><a href="#" class="removeSeminarRow"><i style="margin-top: 10px" class="icon-remove"></i></a></td>
</tr>
My problem starts when i create a new row and leave it empty. The Ajax validation on server side works fine. Yii responds with json that the new field has errors.
{"CvSeminar_1000_title":["Title cannot be empty."],"CvSeminar_1000_yearIssued":["Year cannot be empty"]}
The problem is on client side. Since yiiactiveform does know nothing about the new added row, how can I update yiiactiveform to include the newly added fields ?
Thanks
When you add the new row just update the form settings with the new attribute to validate.
Have a look at the javascript Yii generates so you know what to use.