how to save multi field to "database" in one coulmn

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:



    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');



    $('#remove').click(function() {

    if(i > 2) {





    $('#reset').click(function() {

    while(i > 2) {






    var answers = [];

    $.each($('.field'), function() {



    if(answers.length == 0) {

    answers = "none";




    return false;





in _form:


<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 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>


please i want an answer asap

I’d choose JSON for such structure instead. The saving itself should not be tricky. Get what’s submitted from Yii::$app->request, iterate it with foreach, create an array from it, then json_encode it and make an SQL query.

I’m using this in server side to transform the array in POST into a string before saving it.

//put this in your model class

    public function rules()


        return [

            ['lojas_ids', 'filter', 'filter' => function ($value) {


                    return implode(',',$value);