protected function setOnField(FieldCollection $field, $value)
    {
        if (!is_array($value)) {
            if ($field->getMaxItems() != 1) {
                throw new MultipleFieldAssignmentException('You cannot assign a value to replace a multiple field');
            }

            $field->offsetSet(static::$SINGLE_ITEM_KEY, $value);

            return;
        }

        $field->clear();

        // This happens when the array is
        // replaced completely by another array
        if (count($value)) {
            foreach ($value as $k => $v) {
                $field->offsetSet($k, $v);
            }
        }
    }
protected function setOnField(FieldCollection $field, $value)
    {
        if (!is_array($value)) {
            if ($field->getMaxItems() != 1) {
                throw new MultipleFieldAssignmentException('You cannot assign a value to replace a multiple field');
            }

            $field->offsetSet(static::$SINGLE_ITEM_KEY, $value);

            return;
        }

        $field->clear();

        // This happens when the array is
        // replaced completely by another array
        if (count($value)) {
            foreach ($value as $k => $v) {
                $field->offsetSet($k, $v);
            }
        }
    }
protected function setOnField ( FieldCollection $ field , $ value ) { if ( ! is_array ( $ value ) ) { if ( $ field -> getMaxItems ( ) != 1 ) { throw new MultipleFieldAssignmentException ( 'You cannot assign a value to replace a multiple field' ) ; } $ field -> offsetSet ( static :: $ SINGLE_ITEM_KEY , $ value ) ; return ; } $ field -> clear ( ) ; // This happens when the array is // replaced completely by another array if ( count ( $ value ) ) { foreach ( $ value as $ k => $ v ) { $ field -> offsetSet ( $ k , $ v ) ; } } }
Set values on a field

@param FieldCollection $field
@param $value
@throws MultipleFieldAssignmentException
Set values on a field