Пример #1
0
 /**
  * Creates a form field for the provided model relation field
  * @param zibo\library\html\form\field\FieldFactory $fieldFactory Instance of the field factory
  * @param zibo\library\orm\model\ModelMeta $meta Meta of the model of the relation field
  * @param zibo\library\orm\definition\field\RelationField $field Definition of the relation field
  * @param mixed $value Value for the form field
  * @return zibo\library\html\form\field\Field
  */
 protected function createFormFieldFromRelationField(FieldFactory $fieldFactory, ModelMeta $meta, RelationField $field, $value)
 {
     $relationModel = $meta->getRelationModel($field->getName());
     $list = $relationModel->getDataList();
     if (!is_array($value) && is_object($value)) {
         $value = $value->id;
     }
     $formField = $fieldFactory->createField(FieldFactory::TYPE_LIST, $field->getName(), $value);
     $formField->setOptions($list);
     if ($field instanceof HasManyField) {
         $formField->setIsMultiple(true);
         $formField->setShowSelectedOptionsFirst(true);
     } else {
         $formField->addEmpty('---', '');
     }
     return $formField;
 }
Пример #2
0
 /**
  * Adds a field to generate a join for when parsing the joins
  * @param zibo\library\orm\definition\field\RelationField $field
  * @return null
  */
 private function addFieldJoin(RelationField $field)
 {
     if ($field->isLocalized()) {
         $this->localize = true;
     }
     $this->fieldJoins[$field->getName()] = $field;
 }