Inheritance: extends IgsForm
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     assert('$attributeForm instanceof MultiSelectDropDownAttributeForm');
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $defaultValueOrder = $attributeForm->defaultValueOrder;
     $elementType = $attributeForm->getAttributeTypeName();
     $partialTypeRule = $attributeForm->getModelAttributePartialRule();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $customFieldDataName = $attributeForm->customFieldDataName;
     if ($customFieldDataName == null) {
         $customFieldDataName = ucfirst(strtolower($attributeForm->attributeName));
         //should we do something else instead?
     }
     $customFieldDataData = $attributeForm->customFieldDataData;
     $customFieldDataLabels = $attributeForm->customFieldDataLabels;
     $defaultValue = DropDownDefaultValueOrderUtil::getDefaultValueFromDefaultValueOrder($defaultValueOrder, $customFieldDataData);
     ModelMetadataUtil::addOrUpdateCustomFieldRelation($modelClassName, $attributeName, $attributeLabels, $defaultValue, $isRequired, $isAudited, $elementType, $customFieldDataName, $customFieldDataData, $customFieldDataLabels, 'OwnedMultipleValuesCustomField');
     if ($attributeForm->getCustomFieldDataId() != null) {
         foreach ($attributeForm->customFieldDataData as $order => $newValue) {
             if (isset($attributeForm->customFieldDataDataExistingValues[$order]) && $attributeForm->customFieldDataDataExistingValues[$order] != $newValue) {
                 MultipleValuesCustomField::updateValueByDataIdAndOldValueAndNewValue($attributeForm->getCustomFieldDataId(), $attributeForm->customFieldDataDataExistingValues[$order], $newValue);
             }
         }
     }
     $this->resolveDatabaseSchemaForModel($modelClassName);
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $elementType = $attributeForm->getAttributeTypeName();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $contactStatesData = $attributeForm->contactStatesData;
     $contactStatesLabels = $attributeForm->contactStatesLabels;
     $startingStateOrder = (int) $attributeForm->startingStateOrder;
     $contactStatesDataExistingValues = $attributeForm->contactStatesDataExistingValues;
     if ($contactStatesDataExistingValues == null) {
         $contactStatesDataExistingValues = array();
     }
     if ($attributeForm instanceof ContactStateAttributeForm) {
         //update order on existing states.
         //delete removed states
         $states = ContactState::getAll('order');
         $stateNames = array();
         foreach ($states as $state) {
             if (in_array($state->name, $contactStatesDataExistingValues)) {
                 //todo: just don't match up the swap
                 $order = array_search($state->name, $contactStatesDataExistingValues);
                 $state->name = $contactStatesData[$order];
                 $state->order = $order;
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
                 $saved = $state->save();
                 assert('$saved');
                 $stateNames[] = $state->name;
             } elseif (in_array($state->name, $contactStatesData)) {
                 $stateNames[] = $state->name;
                 $state->order = array_search($state->name, $contactStatesData);
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
                 $saved = $state->save();
                 assert('$saved');
             } else {
                 $stateNames[] = $state->name;
                 $state->delete();
             }
         }
         //add new states with correct order.
         foreach ($contactStatesData as $order => $name) {
             if (!in_array($name, $stateNames)) {
                 $state = new ContactState();
                 $state->name = $name;
                 $state->order = $order;
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $order);
                 $saved = $state->save();
                 assert('$saved');
             }
         }
         //Set starting state by order.
         ContactsUtil::setStartingStateByOrder($startingStateOrder);
         ModelMetadataUtil::addOrUpdateRelation($modelClassName, $attributeName, $attributeLabels, $elementType, $isRequired, $isAudited, 'ContactState');
     } else {
         throw new NotSupportedException();
     }
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     assert('$attributeForm instanceof CurrencyValueAttributeForm');
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $elementType = $attributeForm->getAttributeTypeName();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     ModelMetadataUtil::addOrUpdateRelation($modelClassName, $attributeName, $attributeLabels, $elementType, $isRequired, $isAudited, 'CurrencyValue');
     $this->resolveDatabaseSchemaForModel($modelClassName);
 }
 public function actionUpdate($id)
 {
     $model = new AttributeForm();
     if (isset($_POST['AttributeForm'])) {
         $model->attributes = $_POST['AttributeForm'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromAttribute($id);
     }
     $groups = CHtml::listData(AttributeGroupDescription::model()->findAll(), 'attribute_group_id', 'name');
     $this->render('create', array('model' => $model, 'groups' => $groups));
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     assert('$attributeForm instanceof DateTimeAttributeForm ||
                     $attributeForm instanceof DateAttributeForm');
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $elementType = $attributeForm->getAttributeTypeName();
     $partialTypeRule = $attributeForm->getModelAttributePartialRule();
     $defaultValueCalculationType = $attributeForm->defaultValueCalculationType;
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $mixedRule = array('dateTimeDefault', 'value' => $defaultValueCalculationType);
     ModelMetadataUtil::addOrUpdateMember($modelClassName, $attributeName, $attributeLabels, null, null, null, null, null, $isRequired, $isAudited, $elementType, $partialTypeRule, $mixedRule);
     $this->resolveDatabaseSchemaForModel($modelClassName);
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     assert('$attributeForm instanceof DropDownAttributeForm');
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $defaultValueOrder = $attributeForm->defaultValueOrder;
     $elementType = $attributeForm->getAttributeTypeName();
     $partialTypeRule = $attributeForm->getModelAttributePartialRule();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $customFieldDataName = $attributeForm->customFieldDataName;
     if ($customFieldDataName == null) {
         $customFieldDataName = ucfirst(strtolower($attributeForm->attributeName));
         //should we do something else instead?
     }
     $customFieldDataData = $attributeForm->customFieldDataData;
     $customFieldDataLabels = $attributeForm->customFieldDataLabels;
     $defaultValue = DropDownDefaultValueOrderUtil::getDefaultValueFromDefaultValueOrder($defaultValueOrder, $customFieldDataData);
     ModelMetadataUtil::addOrUpdateCustomFieldRelation($modelClassName, $attributeName, $attributeLabels, $defaultValue, $isRequired, $isAudited, $elementType, $customFieldDataName, $customFieldDataData, $customFieldDataLabels);
     if ($attributeForm->getCustomFieldDataId() != null) {
         $oldAndNewValuePairs = array();
         foreach ($attributeForm->customFieldDataData as $order => $newValue) {
             if (isset($attributeForm->customFieldDataDataExistingValues[$order]) && $attributeForm->customFieldDataDataExistingValues[$order] != $newValue) {
                 CustomField::updateValueByDataIdAndOldValueAndNewValue($attributeForm->getCustomFieldDataId(), $attributeForm->customFieldDataDataExistingValues[$order], $newValue);
                 $oldValue = $attributeForm->customFieldDataDataExistingValues[$order];
                 $oldAndNewValuePairs[$oldValue] = $newValue;
             }
         }
         if (count($oldAndNewValuePairs) > 0) {
             DropDownDependencyDerivedAttributeDesignerUtil::updateValueInMappingByOldAndNewValue($modelClassName, $attributeName, $oldAndNewValuePairs, $attributeForm->customFieldDataDataExistingValues[$order], $newValue);
         }
         DropDownDependencyDerivedAttributeDesignerUtil::resolveValuesInMappingWhenValueWasRemoved($modelClassName, $attributeName, $attributeForm->customFieldDataData);
     }
     $this->resolveDatabaseSchemaForModel($modelClassName);
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     assert('$attributeForm instanceof DropDownDependencyAttributeForm');
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $elementType = $attributeForm->getAttributeTypeName();
     $mappingData = $attributeForm->mappingData;
     $id = $attributeForm->id;
     if ($id != null) {
         $metadata = DropDownDependencyDerivedAttributeMetadata::getById($id);
         $metadata->setScenario('nonAutoBuild');
     } else {
         $metadata = new DropDownDependencyDerivedAttributeMetadata();
         $metadata->setScenario('nonAutoBuild');
     }
     $metadata->name = $attributeName;
     $metadata->modelClassName = $modelClassName;
     $metadata->serializedMetadata = serialize(array('mappingData' => $mappingData, 'attributeLabels' => $attributeLabels));
     $saved = $metadata->save();
     if (!$saved) {
         throw new NotSupportedException();
     }
 }
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('defaultValueCalculationType' => Zurmo::t('ZurmoModule', 'Default Value')));
 }
 /**
  * Override to handle the case when the attributeName was already created used in another module
  */
 public function validateAttributeNameDoesNotExists()
 {
     parent::validateAttributeNameDoesNotExists();
     if (CustomFieldData::getByName($this->attributeName, false)->id > 0) {
         $this->addError('attributeName', Zurmo::t('DesignerModule', 'A field with this name and data is already used in another module.'));
     }
 }
 public function rules()
 {
     return array_merge(parent::rules(), array(array('defaultValue', 'boolean')));
 }
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('formula' => Zurmo::t('DesignerModule', 'Formula')));
 }
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('contactStatesData' => Zurmo::t('ContactsModule', 'Contact Statuses'), 'startingStateOrder' => Zurmo::t('ContactsModule', 'Starting Status'), 'contactStatesLablsa' => Zurmo::t('ContactsModule', 'Contact Status Translated Labels')));
 }
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('required' => Zurmo::t('ContactWebFormsModule', 'Required?'), 'hidden' => Zurmo::t('ContactWebFormsModule', 'Hidden?')));
 }
 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $defaultValue = $attributeForm->defaultValue;
     $elementType = $attributeForm->getAttributeTypeName();
     $partialTypeRule = $attributeForm->getModelAttributePartialRule();
     //should we keep this here with (boolean)?
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     if (!$attributeForm instanceof DropDownAttributeForm) {
         if ($defaultValue === '') {
             $defaultValue = null;
         }
         if ($attributeForm instanceof MaxLengthAttributeForm) {
             if ($attributeForm->maxLength != null) {
                 $maxLength = (int) $attributeForm->maxLength;
             } else {
                 $maxLength = null;
             }
         } else {
             $maxLength = null;
         }
         if ($attributeForm instanceof MinMaxValueAttributeForm) {
             if ($attributeForm->minValue != null) {
                 $minValue = (int) $attributeForm->minValue;
             } else {
                 $minValue = null;
             }
             if ($attributeForm->maxValue != null) {
                 $maxValue = (int) $attributeForm->maxValue;
             } else {
                 $maxValue = null;
             }
         } else {
             $minValue = null;
             $maxValue = null;
         }
         if ($attributeForm instanceof DecimalAttributeForm) {
             $precision = (int) $attributeForm->precisionLength;
         } else {
             $precision = null;
         }
         ModelMetadataUtil::addOrUpdateMember($modelClassName, $attributeName, $attributeLabels, $defaultValue, $maxLength, $minValue, $maxValue, $precision, $isRequired, $isAudited, $elementType, $partialTypeRule);
         $this->resolveDatabaseSchemaForModel($modelClassName);
     } else {
         throw new NotSupportedException();
     }
 }
 /**
  * (non-PHPdoc)
  * @see AttributeForm::validateAttributeNameDoesNotExists()
  */
 public function validateAttributeNameDoesNotExists()
 {
     assert('$this->modelClassName != null');
     parent::validateAttributeNameDoesNotExists();
     try {
         $models = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName($this->attributeName, $this->modelClassName);
         if (count($models) > 0) {
             $this->addError('attributeName', Zurmo::t('DesignerModule', 'A field with this name is already used.'));
         }
     } catch (NotFoundException $e) {
     }
 }
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('maxLength' => Zurmo::t('DesignerModule', 'Maximum Length')));
 }
 /**
  * Override to remove any valuesToParentValues where the attributeName is null.
  * @see AttributeForm::sanitizeFromPostAndSetAttributes()
  */
 public function sanitizeFromPostAndSetAttributes($values)
 {
     assert('is_array($values)');
     if (isset($values['mappingData'])) {
         foreach ($values['mappingData'] as $position => $data) {
             if ($data['attributeName'] == null && isset($data['valuesToParentValues'])) {
                 unset($values['mappingData'][$position]['valuesToParentValues']);
             }
         }
     }
     parent::sanitizeFromPostAndSetAttributes($values);
 }