예제 #1
0
 /**
  * Override needed to translate defaultValue to the order.  Order corresponds to the keyed index of the
  * customFieldDataData array.  This is needed for the form to operate correctly in the user interface.
  * Otherwise if you select a default as a new pick list item, the user interface has no way of posting
  * the correct Id for the defaultValue since the new pick list item has not been created yet.
  * Also need override to properly adapt pick list items.
  */
 public function __construct(RedBeanModel $model = null, $attributeName = null)
 {
     parent::__construct($model, $attributeName);
     if ($model !== null) {
         $this->customFieldDataName = $model->{$attributeName}->data->name;
         $this->customFieldDataId = $model->{$attributeName}->data->id;
         $this->customFieldDataData = unserialize($model->{$attributeName}->data->serializedData);
         if ($model->{$attributeName}->data->serializedLabels !== null) {
             $this->customFieldDataLabels = unserialize($model->{$attributeName}->data->serializedLabels);
         }
         $this->defaultValueOrder = DropDownDefaultValueOrderUtil::getDefaultValueOrderFromDefaultValue($this->defaultValue, $this->customFieldDataData);
     }
 }