public static function bulidRelationsOnFK(TableMap $map) { $map->relationsFK = array(); /** @var $relation RelationMap */ foreach ($map->getRelations() as $relation) { /** @var $localColumn ColumnMap */ if (count($relation->getLocalColumns()) > 1) { //TODO $x = 0; } $localColumn = $relation->getLocalColumns()[0]; $map->relationsFK[$localColumn->getName()] = $relation; } }
/** * Fills the form with the values from a model instance. * * @param \BaseObject $instance */ public function fillForm(\BaseObject $instance) { foreach ($this->getFieldColumns() as $column) { $field = $this->getField($this->getColumnName($column)); if ($field) { $field->setValue($this->getColumnValue($instance, $column)); } } foreach ($this->modelMap->getRelations() as $relation) { $name = 'relation__' . strtolower($relation->getName()); $field = $this->getField($name); if ($field) { $field->setValue($this->getRelationValue($instance, $relation)); } } if (is_callable($this->onFillForm)) { call_user_func($this->onFillForm, $instance, $this); } }
/** * Fills the form with the values from a model instance. * * @param BaseObject $instance */ public function fillForm(BaseObject $instance) { foreach ($this->getElementColumns() as $column) { $element = $this->getElement(strtolower($column->getName())); if ($element) { $element->setValue($this->getColumnValue($instance, $column)); } } foreach ($this->modelMap->getRelations() as $relation) { $name = 'relation__' . strtolower($relation->getName()); $element = $this->getElement($name); if ($element) { $element->setValue($this->getRelationValue($instance, $relation)); } } if (is_callable($this->onFillForm)) { call_user_func($this->onFillForm, $instance, $this); } }