hello guys, i have form with dynamic text field i can add and remove text field in that form. But i have problem, i want to make rules validation for every textfield in that form. Do you have answer for my problem ?
hello guys, i have form with dynamic text field i can add and remove text field in that form. But i have problem, i want to make rules validation for every textfield in that form. Do you have answer for my problem ?
MY FORM
<?php Yii::app()->clientScript->registerScript('textFieldAdder','$("#additional-link").bind("click",function(){
var id="optional_text";
var size=$("#additional-inputs > li input").size();
$("#additional-inputs").append("<li><input type=text id="+id+size+" name="+id+"["+size+"]></li>");
})')?>
<?php $form = $this->beginWidget('CActiveForm', array(
'id'=>'user-form',
'enableAjaxValidation'=>true,
)); ?>
<?php echo CHtml::link('Add input','#',array('id'=>'additional-link')); ?>
<ul>
<div id="additional-inputs">
<li><?php echo CHtml::textfield('optional_text[0]','');?></li>
</div>
</ul>
<?php echo CHtml::submitButton('Submit');?>
<?php $this->endWidget('CActiveForm');?>
copy from haensel
Will this tutorial help you? You may need to add error message part under textfield.
yes