/** * Create form field from relation. * * @param \RelationMap $relation * @return Entity */ public function createFieldFromRelation(\RelationMap $relation) { $name = 'relation__' . strtolower($relation->getName()); $toMany = self::isRelationTypeToMany($relation->getType()); $options = array('id' => $name . rand(), 'type' => $toMany ? 'multiplechoice' : 'choice', 'label' => $relation->getName() . ($toMany ? 's' : ''), 'choices' => $this->getChoicesFromRelation($relation)); $this->createField($name, $options); }
public function __toString() { return parent::toString() . ' tableMap: ' . ($this->tableMap ? get_class($this->tableMap) : 'null') . ' relationMap: ' . $this->relationMap->getName() . ' previousJoin: ' . ($this->previousJoin ? '(' . $this->previousJoin . ')' : 'null') . ' relationAlias: ' . $this->rightTableAlias; }
/** * Create form element from relation. * * @param RelationMap $relation * @return Zend_Form_Element */ public function createElementFromRelation(RelationMap $relation) { $name = 'relation__' . strtolower($relation->getName()); $options = array('id' => $name . rand(), 'multiOptions' => $this->getMultiOptsFromRelation($relation)); switch ($relation->getType()) { case RelationMap::ONE_TO_MANY: case RelationMap::MANY_TO_MANY: $options['label'] = $relation->getName() . 's'; $element = $this->createElement('multiselect', $name, $options); break; case RelationMap::MANY_TO_ONE: case RelationMap::ONE_TO_ONE: $options['label'] = $relation->getName(); $element = $this->createElement('select', $name, $options); break; } return $element; }