i want to save the array called "answers" to database in one column called "EM_PHONE" with a comma between the date-fields instead of showing it as "alert".
Note: i didn’t add any changes to “Controller” and “Model”
script code:
<script>
$(document).ready(function(){
var i = $('input').size() + 1;
$('#add').click(function() {
$('<?php echo $form->textField($model, 'EM_PHONE', array('class' => 'field form-group form-control'))?>').fadeIn('slow').appendTo('.inputs');
i++;
});
$('#remove').click(function() {
if(i > 2) {
$('.field:last').remove();
i--;
}
});
$('#reset').click(function() {
while(i > 2) {
$('.field:last').remove();
i--;
}
});
$('.submit').click(function(){
var answers = [];
$.each($('.field'), function() {
answers.push($(this).val());
});
if(answers.length == 0) {
answers = "none";
}
alert(answers);
return false;
});
});
</script>
[b]
in _form:
[/b]
<div class="form-group col-lg-12 row inputs">
<?php echo $form->textFieldGroup($model, 'EM_PHONE', array('wrapperHtmlOptions' => array('class' => ''), 'widgetOptions' => array('htmlOptions' => array('placeholder' => 'Type Phone Number to verify.')), 'prepend' => '<i class="glyphicon glyphicon-glass"></i>')); ?>
</div>
<div class="form-group">
<a class="btn btn-xs btn-info" id="add">Add Another</a>
<a class="btn btn-xs btn-danger" id="remove">Remove</a>
</div>