Ejemplo n.º 1
0
 /**
  * Set default.
  *
  * The default value here should be one of the existing list of options.
  *
  * @param array $value default value.
  * @return OKT_FormElement  fluent interface
  */
 function setDefault($value)
 {
     if (!array_key_exists($value, $this->options)) {
         throw new InvalidArgumentException("default {$value} is not in options");
     }
     return parent::setDefault($value);
 }
Ejemplo n.º 2
0
 /**
  * Sets an attribute on a particular member.
  *
  * @param string $name  attribute name
  * @param mixed  $value  attribute value
  * @return T_Form_Element  fluent
  */
 function setAttribute($name, $value)
 {
     if (strcasecmp($name, 'maxlength') === 0) {
         $this->setMaxLength($value);
         // enforce max length if set
     }
     return parent::setAttribute($name, $value);
 }
Ejemplo n.º 3
0
 /**
  * Set default.
  *
  * The default value here is an array of values that should be checked by
  * default. On input, these default values are checked to see they are
  * already options.
  *
  * @param array $value default value.
  * @return OKT_FormElement  fluent interface
  */
 function setDefault($value)
 {
     if (!is_array($value)) {
         throw new InvalidArgumentException('default required as array');
     }
     $intersect = array_intersect(array_keys($this->getOptions()), $value);
     if (count($intersect) !== count($value)) {
         throw new InvalidArgumentException('default values not in options');
     }
     return parent::setDefault(array_values($intersect));
 }
Ejemplo n.º 4
0
 /**
  * Gets the error label markup.
  *
  * @param T_Form_Element $node
  * @return string
  */
 protected function getErrorLabelMarkup(T_Form_Element $node)
 {
     if (!$node->isValid()) {
         $msg = $this->escape($node->getError()->getMessage());
         return " <strong>{$msg}</strong>";
     }
     return '';
 }
Ejemplo n.º 5
0
 /**
  * Validate element.
  *
  * @param T_Cage_Array $source  source to validate
  */
 function validate(T_Cage_Array $source)
 {
     $this->is_validated = true;
     return parent::validate($source);
 }