Saving a multiple select as attribute

Permalink
Currently running into a issue where my multiple selects are being saved in the attribute.

Is there a certain want you have to format the array to save it correctly for C5 to pick it up?

<div class="form-group col-md-12">
    <?= $form->label('pageTypeOfColors[]',t('Type of Colors'));?>
    <select multiple id='pageTypeOfColors' name='pageTypeOfColors[]' class="form-control">
        <?php foreach($pageTypeOfColors as $i=>$j) {
            if(is_array($pageTypeOfColorsSaved) && in_array($i,$pageTypeOfColorsSaved))
                echo "<option selected value=".$i.">".$j."</option>";
            else
                echo "<option value=".$i.">".$j."</option>";
        }?>
    </select>
</div>


public function view()
{
    // getting select options
    $ak = CollectionAttributeKey::getByHandle('type_of_Colors');
    $akc = $ak->getController();
    $values = $akc->getOptions();
    $typeOfColors = array();
    foreach($values as $v)
    {
        $typeOfColors[$v->getSelectAttributeOptionID()] = $v->getSelectAttributeOptionValue();
    }
    $this->set('pageTypeOfColors', $typeOfColors)
    // saved color from database for later editing.
    $this->set('pageTypeOfColorsSaved',explode(',',$result['akPageTypeOfColors']));
}

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi Heihachi,

This tutorial discusses how to use the Select Multiple form widget:
https://documentation.concrete5.org/tutorials/how-to-use-the-form-wi...