Commits

Dave Gauer committed 5edb60a

Added errorIfNotChecked() for checkboxes. Wrote test for it as well.

  • Participants
  • Parent commits 85b8dc1

Comments (0)

Files changed (2)

 		}
 	}
 
+	public function errorIfNotChecked($name, $message){
+		if(!$this->checked($name)){
+			$this->setError($name, $message);
+		}
+	}
+
 	public function hasErrors(){
 		foreach($this->elements as $e){
 			if(count($e->errorMessages) > 0){
  *	form validation tests
  */
 
-// TODO
-
+$form = new PhormalWear("validation tests");
+$form->add("checkbox", "agree", "I accept terms");
+$form->errorIfNotChecked("agree", "You must accept the terms!");
+$form->showErrors('agree');
+$t->check_output('<div class="form-field-error">You must accept the terms!</div>');
+// TODO: the rest of these!
 
 /******************************************************************************
  *	array torture tests with every type of form element