Esempio n. 1
0
 /**
  * Adds an error message to the field
  * This is normally called by one of the validators
  * @param string $msg
  */
 public function addError($msg)
 {
     // Does this field bubble its error messages up to its parent?
     $bubbleErrors = $this->get('bubble_errors', false);
     if (!$bubbleErrors) {
         // nope, so store them here
         $this->errors[] = $msg;
         return;
     }
     // if we have a parent, push the error up there
     if ($this->parent != null) {
         $this->parent->addError($msg);
     }
 }
Esempio n. 2
0
 /**
  * Determine if this class is valid
  * @return bool
  */
 public function isValid()
 {
     // Find out if I am valid
     $valid = parent::isValid();
     // and ask all my children.
     // We always ask everyone, even if the first thing says it isn't valid
     // as this will collect up all the errors in the entire form, so they
     // can all be display, instead of just the first one.
     foreach ($this->children as $child) {
         // if my child isn't valid, then make a note of it
         if (!$child->isValid()) {
             $valid = false;
         }
     }
     // return my state.
     return $valid;
 }