Source of file MetadataSelectFieldOption.php
Size: 1,008 Bytes - Last Modified: 2021-12-23T10:25:41+00:00
/var/www/docs.ssmods.com/process/src/code/dataobjects/fields/MetadataSelectFieldOption.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | <?php /** * @package silverstripe-metadata */ class MetadataSelectFieldOption extends DataObject { private static $db = array( 'Key' => 'Varchar(100)', 'Value' => 'Varchar(255)', 'Sort' => 'Int', ); private static $has_one = array( 'Parent' => 'MetadataSelectField' ); private static $summary_fields = array( 'Key', 'Value' ); /** * @return string */ public function getKey() { return ($key = $this->getField('Key')) ? $key : $this->Value; } public function validate() { $result = parent::validate(); if (!$this->Value) { $result->error('Each select option must have a value.'); } return $result; } public function singular_name() { return 'Option'; } public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('ParentID'); return $fields; } } |