Example #1
0
 /**
  * Performs the form validation workflow.
  *
  * @param string $submit_button
  * @param string $form_config
  * @param array $default_fields
  * @return null if no submit sent. True if validated correctly, false otherwise.
  */
 protected function getValidatedForm($submit_button, $form_config, $default_fields = array())
 {
     $post = FilterPost::getInstance();
     $form = new Form($post, $this->view);
     if ($post->isSent($submit_button)) {
         $return = $form->validateElements($form_config);
         if ($return) {
             $return = $form;
         }
     } else {
         $form->addFields($default_fields);
         $return = null;
     }
     $this->assign('form_values', $form->getFields());
     $this->assign('requirements', $form->getRequirements($form_config));
     $this->assign('error', $form->getErrors());
     return $return;
 }