Exemplo n.º 1
0
 public function returnField($form_name, $name, $value = '')
 {
     $field = '';
     foreach ($this->options as $key => $val) {
         $attributes = $this->getAttributeString($val);
         $field .= sprintf('<input type="checkbox" name="%6$s[%1$s][]" id="%6$s_%3$s" value="%2$s" %4$s/>' . '<label for="%6$s_%3$s">%5$s</label>', $name, $key, Useful::slugify($name) . '_' . Useful::slugify($key), (is_array($value) && in_array((string) $key, $value) ? 'checked="checked"' : '') . $attributes['string'], $attributes['val'], $form_name);
     }
     $class = !empty($this->error) ? 'error choice_label' : 'choice_label';
     return array('messages' => !empty($this->custom_error) && !empty($this->error) ? $this->custom_error : $this->error, 'label' => $this->label == false ? false : sprintf('<label class="%s">%s</label>', $class, $this->label), 'field' => $field, 'html' => $this->html);
 }
Exemplo n.º 2
0
 public function validate($val)
 {
     if ($this->required) {
         if (Useful::stripper($val) === false) {
             $this->error[] = 'is required';
         }
     }
     if (in_array($val, $this->false_values)) {
         $this->error[] = "{$val} is not a valid choice";
     }
     return !empty($this->error) ? false : true;
 }
Exemplo n.º 3
0
 public function validate($val)
 {
     if (!empty($this->error)) {
         return false;
     }
     if (parent::validate($val)) {
         if (Useful::stripper($val) !== false) {
             if (!filter_var($val, FILTER_VALIDATE_FLOAT)) {
                 $this->error[] = 'must be numeric';
             }
         }
     }
     return !empty($this->error) ? false : true;
 }
Exemplo n.º 4
0
 public function validate($val)
 {
     if ($this->required) {
         if (Useful::stripper($val) === false) {
             $this->error[] = 'is required';
         }
     }
     if (Useful::stripper($val) !== false) {
         if (!preg_match($this->content, $val)) {
             $this->error[] = 'is not valid';
         }
     }
     return !empty($this->error) ? false : true;
 }
Exemplo n.º 5
0
 public function validate($val)
 {
     if (!empty($this->error)) {
         return false;
     }
     if (parent::validate($val)) {
         if (Useful::stripper($val) !== false) {
             if ($this->min_length && strlen($val) < $this->min_length) {
                 $this->error[] = sprintf('must be more than %s characters', $this->min_length);
             }
             if ($this->alphanumeric && (!preg_match("/[A-Za-z]+/", $val) || !preg_match("/[0-9]+/", $val))) {
                 $this->error[] = 'must have at least one alphabetic character and one numeric character';
             }
         }
     }
     if ($this->confirm) {
         $request = strtoupper($this->form->getMethod()) == 'POST' ? $_POST : $_GET;
         if ($val != $request[$this->form->getName()][$this->confirm]) {
             $this->error[] = 'The passwords provided do not match password';
         }
     }
     return !empty($this->error) ? false : true;
 }
Exemplo n.º 6
0
 public function addConfirmation($field_name, array $attributes = array())
 {
     $this->form->addField($field_name, 'email', $attributes + $this->attributes);
     $this->confirm = Useful::slugify($field_name, '_');
 }