Hi, I’m new to yii framework.
I want to duplicate the textfield when the user clicks add button and is able to delete the textfield when they click the delete button. Currently, I’m using jqrelcopy extension to do so.
I have a problem at the controller side. I can’t seem to retrieve all the duplicated textfields values. I can only retrieve the last textfield value based on the textfield name using the codes shown below. I realised that using “$_POST[‘Contact’][‘contact_email’]” in the controller would only give me the textfield value of the last textfield because all the duplicated textfields will have the same name, only the textfield id will be different.
Hence, I think that I need to get the value of the textfield using textfield id instead of textfield name at the controller side. Is there any way of doing that?
I can’t seem to find much examples of jqrelcopy on the controller. Those that I saw I can’t really understand. Is there any other way that I can modify my codes below to get all the values of the duplicated textfields in the controller?
Below are a portion of my codes:
View:
<?php
$form=$this->beginWidget('CActiveForm', array(
'id'=>'contact-form',
'enableAjaxValidation'=>false,
'enableClientValidation' => true,
'action'=>array('Default/SubmitContact'),
));
?>
<div class="row copy">
<?php echo $form->textField($model,'contact_number',array('size'=>35,'maxlength'=>100)); ?>
<?php echo $form->textField($model,'contact_email',array('size'=>35,'maxlength'=>100)); ?>
</div>
<?php $this->endWidget(); ?>
Controller:
if(isset($_POST['Contact']))
{
echo $_POST['Contact']['contact_number'];
echo $_POST['Contact']['contact_email'];
}