示例#1
0
 /**
  * Accepted options for Captcha:
  * - captcha: a valid Zend\Captcha\AdapterInterface
  *
  * @param array|\Traversable $options
  * @return Captcha
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['captcha'])) {
         $this->setCaptcha($options['captcha']);
     }
     return $this;
 }
示例#2
0
 /**
  * Retrieve the element value
  *
  * If the value is a DateTime object, and $returnFormattedValue is true
  * (the default), we return the string
  * representation using the currently registered format.
  *
  * If $returnFormattedValue is false, the original value will be
  * returned, regardless of type.
  *
  * @param  bool $returnFormattedValue
  * @return mixed
  */
 public function getValue($returnFormattedValue = true)
 {
     $value = parent::getValue();
     if (!$value instanceof PhpDateTime || !$returnFormattedValue) {
         return $value;
     }
     $format = $this->getFormat();
     return $value->format($format);
 }
示例#3
0
 /**
  * Set a single element attribute
  *
  * @param  string $key
  * @param  mixed  $value
  * @return Select|ElementInterface
  */
 public function setAttribute($key, $value)
 {
     // Do not include the options in the list of attributes
     // TODO: Deprecate this
     if ($key === 'options') {
         $this->setValueOptions($value);
         return $this;
     }
     return parent::setAttribute($key, $value);
 }
示例#4
0
 /**
  * Accepted options for MultiCheckbox:
  * - use_hidden_element: do we render hidden element?
  * - unchecked_value: value for checkbox when unchecked
  * - checked_value: value for checkbox when checked
  *
  * @param  array|\Traversable $options
  * @return Checkbox
  */
 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($options['use_hidden_element'])) {
         $this->setUseHiddenElement($options['use_hidden_element']);
     }
     if (isset($options['unchecked_value'])) {
         $this->setUncheckedValue($options['unchecked_value']);
     }
     if (isset($options['checked_value'])) {
         $this->setCheckedValue($options['checked_value']);
     }
     return $this;
 }
示例#5
0
 /**
  * Override: get attributes
  *
  * Seeds 'value' attribute with validator hash
  *
  * @return array
  */
 public function getAttributes()
 {
     $attributes = parent::getAttributes();
     $validator = $this->getCsrfValidator();
     $attributes['value'] = $validator->getHash();
     return $attributes;
 }