示例#1
0
 public function createNewOption($name, $value, $itemdata = null)
 {
     if ($this->getType() == self::CALCULATED_FIELD) {
         // Only allow one option/formula for the calculated field
         $opts = $this->getOptions();
         foreach ($opts as $option) {
             $option->delete();
         }
     }
     $option = new CustomDatatypeOption();
     $option->setName($name);
     $option->setKey($this->getKey());
     $option->setValue($value);
     $option->setItemdata($itemdata);
     $option->setCustomdatatype($this->_id);
     $option->save();
     // In order to set permissions correctly the item type has to be the same
     // as the option id not the item field. set the opton id with the newly generated
     // option ID and save again
     $option->setItemtype($option->getID());
     $option->save();
     $this->_options = null;
     return $option;
 }