public function isValid(\form\Field $field)
 {
     if (!is_null($field->get_param('value'))) {
         return in_array($field->get_param('value'), $this->_array);
     }
     return false;
 }
 public function isValid(\form\Field $field)
 {
     if (!is_null($field->get_param('value'))) {
         return preg_match($this->_regex, $field->get_param('value'));
     }
     return false;
 }
예제 #3
0
 /**
  * @param string $name
  * set default values
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setStorable(true);
     $this->setDataType('varchar(10)');
     $this->setFormat('d-m-Y H:i');
 }
 public function isValid(\form\Field $field)
 {
     if (!is_null($field->get_param('value'))) {
         if ($this->_required && empty($field->get_param('value')) || is_numeric($field->get_param('value')) === false) {
             return false;
         }
         $value = (int) $field->get_param('value');
         if ($value > $this->_max) {
             return false;
         }
         if ($value < $this->_min) {
             return false;
         }
         return true;
     }
     return false;
 }
 /**
  * Ajoute un champ au formulaire
  *
  * @param string $name    Le nom du champ
  * @param \form\Field $field l'objet champ
  * @param int $iteration iteration du champ / si null, champ unique
  *
  * @return $this->fields
  */
 protected function addField($name, \form\Field $field, $iteration = null)
 {
     $real_field_name = $this->get_name() . "[" . $name . "]";
     if (!is_null($iteration)) {
         $real_field_name .= "[" . $iteration . "]";
     }
     $field->add_param('name', $real_field_name);
     if (isset($this->post[$this->get_name()][$name])) {
         if (!is_null($iteration)) {
             $field->add_param('value', $this->post[$this->get_name()][$name][$iteration]);
         } else {
             $field->add_param('value', $this->post[$this->get_name()][$name]);
         }
     }
     if (!is_null($iteration)) {
         $this->fields[$name][$iteration] = $field;
     } else {
         $this->fields[$name] = $field;
     }
     return $this->fields;
 }
예제 #6
0
 /**
  * @param string $name
  * set default values
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setStorable(true);
     $this->setDataType('varchar(255)');
 }
예제 #7
0
 /**
  * @param string $name
  * set default values
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $this->setStorable(true);
     $this->setDataType('int(11)');
 }