protected function validate_this() { $this->strip_error(); $done_already = FALSE; if ($this->value and $this->rule) { foreach (Formo::into_array($this->rule) as $rule) { if (!$this->_do_rule($rule)) { $this->error = $this->error_msg; $this->error = (is_array($rule) and isset($rule['error_msg'])) ? $rule['error_msg'] : $this->error_msg; break; } } } elseif ($this->required and strtoupper($this->required !== 'FALSE') and strtoupper($this->required) !== 'F' and !Formo::has_value($this->value)) { $this->error = $this->required_msg; } }
/** * validate method. run validation through all elements in group * */ function validate() { Event::run('formogroup.pre_validate', $this); foreach ($this->elements as $element => $value) { $this->{$element}->validate(); } if ($this->required and !Formo::has_value(Input::instance()->post($this->name))) { $this->error = $this->required_msg; $this->add_class($this->error_class); return $this->error; } elseif ($this->rule) { $rules = !is_array($this->rule) ? array($this->rule) : $this->rule; foreach ($rules as $rule) { $function = isset($rule['rule']) ? $rule['rule'] : $rule; $error_msg = isset($rule['error_msg']) ? $rule['error_msg'] : $this->error_msg; $type = $this->post_type; if (!call_user_func($function, Input::instance()->{$type}($this->name))) { $this->error = $error_msg; $this->add_class($this->error_class); return $this->error; } } } Event::run('formogroup.post_validate', $this); }