feature/formhandler
Sven Slootweg 11 years ago
parent 5c6445a023
commit fc318180f7

@ -95,12 +95,14 @@ class CPHPFormValidatorPromiseBaseClass
public function Either($error_message) public function Either($error_message)
{ {
$this->next = new CPHPFormValidatorOperatorEither($this, $error_message, array_slice(func_get_args(), 1)); $this->next = new CPHPFormValidatorOperatorEither($this, $error_message, array_slice(func_get_args(), 1));
$this->next->handler = $this->handler;
return $this->next; return $this->next;
} }
public function All($error_message) public function All($error_message)
{ {
$this->next = new CPHPFormValidatorOperatorAll($this, $error_message, array_slice(func_get_args(), 1)); $this->next = new CPHPFormValidatorOperatorAll($this, $error_message, array_slice(func_get_args(), 1));
$this->next->handler = $this->handler;
return $this->next; return $this->next;
} }
@ -110,6 +112,7 @@ class CPHPFormValidatorPromiseBaseClass
$this->next = new CPHPFormValidatorPromise($this, $this->handler, $key, array(), "required", "A value is required for this field.", $critical, function($key, $value, $args, $handler){ $this->next = new CPHPFormValidatorPromise($this, $this->handler, $key, array(), "required", "A value is required for this field.", $critical, function($key, $value, $args, $handler){
return isset($handler->formdata[$key]); return isset($handler->formdata[$key]);
}); });
$this->next->handler = $this->handler;
return $this->next; return $this->next;
} }
@ -118,6 +121,7 @@ class CPHPFormValidatorPromiseBaseClass
$this->next = new CPHPFormValidatorPromise($this, $this->handler, $key, array(), "email", "The value is not a valid e-mail address.", $critical, function($key, $value, $args, $handler){ $this->next = new CPHPFormValidatorPromise($this, $this->handler, $key, array(), "email", "The value is not a valid e-mail address.", $critical, function($key, $value, $args, $handler){
return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
}); });
$this->next->handler = $this->handler;
return $this->next; return $this->next;
} }
} }
@ -218,12 +222,12 @@ class CPHPFormValidatorOperatorEither extends CPHPFormValidatorOperator
if(count($exceptions) == count($this->children)) if(count($exceptions) == count($this->children))
{ {
$exceptions[] = array( return array(array(
"type" => "operator", "type" => "operator",
"error_type" => "either", "error_type" => "either",
"error_msg" => $this->error_message, "error_msg" => $this->error_message,
"children" => $exceptions "children" => $exceptions
); ));
} }
else else
{ {
@ -248,12 +252,12 @@ class CPHPFormValidatorOperatorAll extends CPHPFormValidatorOperator
if(count($exceptions) > 0) if(count($exceptions) > 0)
{ {
$exceptions[] = array( return array(array(
"type" => "operator", "type" => "operator",
"error_type" => "both", "error_type" => "both",
"error_msg" => $this->error_message, "error_msg" => $this->error_message,
"children" => $exceptions "children" => $exceptions
); ));
} }
else else
{ {

Loading…
Cancel
Save