/** * If no title column has been set on this OptionGroups object directly, * we attempt to get it from the OptionPairs object, if present. This * allows a user to set a custom title column on OptionPairs and have it * automatically take effect on OptionGroups as well. Otherwise, we'll * revert back to the standard auto-detection behavior. * * @throws TitleColumnNotDetectedException * @param array $columns The "columns" portion of the table metadata. * @return string */ protected function findTitleColumnFromMetadata(array $columns) { if ($this->optionPairs->hasTitleColumn()) { return $this->optionPairs->getTitleColumn(); } else { return parent::findTitleColumnFromMetadata($columns); } }
/** * Get an OptionPairs object for this field. Allows you to easily * fetch key-value option pairs for foreign keys. * * @return \Dewdrop\Fields\OptionPairs */ public function getOptionPairs() { if (null === $this->optionPairs) { $this->optionPairs = new OptionPairs($this->table->getAdapter()); $ref = $this->getOptionPairsReference(); if ($ref) { $this->optionPairs->setOptions(['tableName' => $ref['table'], 'valueColumn' => $ref['column']]); } } return $this->optionPairs; }