How to handle values for cc/bcc beeing created dynamically

hi guys, first at all, look at my attachement, please. There U can see dynamically created input fields using loop like this:





    <div class="col-md-12">

        <?php

        for ($i = 0; $i < count($geschlecht); $i++) {

            if ($geschlecht[$i] == 1) {

                ?><div class="box"> <?= Html::img($url_symbol_male, ['alt' => 'pic not found', 'title' => 'männlich', 'style' => 'width:35px;height:55px']); ?>

                <?= "<label>" . $name[$i] . "</label>" ?>

                    <?= "<ul><li>" . $Zieladressen[$i] . "</ul></li>" ?><?= $form->field($ZMailAusgangEmpfaenger, 'id_empfaenger_art[]')->checkboxList(array(0 => 'an', 1 => 'bc', 2 => 'bcc')); ?></div><?php

            } else if ($geschlecht[$i] == 2) {

                ?><div class="box"><?= Html::img($url_symbol_female, ['alt' => 'pic not found', 'title' => 'weiblich', 'style' => 'width:35px;height:55px']); ?>

                    <?= "<label>" . $name[$i] . "</label>" ?>

                    <?= "<ul><li>" . $Zieladressen[$i] . "</ul></li>" ?><?= $form->field($ZMailAusgangEmpfaenger, 'id_empfaenger_art')->checkboxList(array(0 => 'an', 1 => 'bc', 2 => 'bcc')); ?></div><?php

                $form->field($ZMailAusgangEmpfaenger, 'id_empfaenger_art')->checkboxList(array(0 => 'an', 1 => 'bc', 2 => 'bcc'));

            } else if ($geschlecht[$i] == 3) {

                ?><div class="box"><?= Html::img($url_symbol_bi, ['alt' => 'pic not found', 'title' => 'Transgender', 'style' => 'width:35px;height:55px']); ?>

                    <?= "<label style='font-weight: lighter';>" . $name[$i] . "</label>" ?>

                    <?= "<ul><li>" . $Zieladressen[$i] . "</ul></li>" ?></div><?php

            }

        }

        ?>

    </div>



Problem creating formular like this are attibutes an,cc and bcc. Each of these values have to be saved into database depending on users choice. If first element in formular will be set to cc, value should be 2, if bcc, value sholud be 3 etc.

Count of elements will be given by an array to Controller. My question is following:

How to save values of checkBoxList into database in principle?

[size=“2”]$ZMailAusgangEmpfaenger->i[/size][size=“2”]d_empfaenger_art [/size]will be overwriten for every element after first one. I’m only able to absorb values once, but i need them for each receiver. Hope, I depicted problem in easy to understand enough