Example #1
0
 /**
  * Constructor
  * 
  * @param \Feeld\Field\DataType\DataTypeInterface $dataType
  * @param array $options
  * @param mixed $id
  * @param \Feeld\Display\DisplayInterface $display
  * @throws \Wellid\Exception\DataType
  */
 public function __construct(DataType\DataTypeInterface $dataType = null, array $options = array('yes' => 1, 'no' => 0), $id = null, \Feeld\Display\DisplayInterface $display = null)
 {
     if (count($options) !== 2) {
         throw new \Wellid\Exception\DataType('options', 'array with two values', $options);
     }
     if (is_null($dataType)) {
         $dataType = new \Feeld\DataType\Boolean(new \Sanitor\Sanitizer(FILTER_SANITIZE_NUMBER_INT));
         $options = array('yes' => 1, 'no' => 0);
     }
     parent::__construct($dataType, $id, $display);
     foreach ($options as $key => $value) {
         $this->addOption($key, $value);
     }
 }
Example #2
0
 /**
  * On setting a default value, the (unfiltered) value of this field is
  * also set to the same value
  * 
  * @param mixed $value
  * @return Constant
  */
 public function setDefault($value)
 {
     parent::setDefault($value);
     $this->setRawValue($value);
     return $this;
 }