Example #1
0
 public static function doOnSuccess()
 {
     if (!self::$form_conf_id) {
         return;
     }
     if (!is_numeric(self::$form_conf_id)) {
         return;
     }
     $form_config = \Taco\Post::find(self::$form_conf_id);
     if (!\AppLibrary\Obj::iterable($form_config)) {
         return;
     }
     $on_success = $form_config->get('on_success');
     if (!is_callable($on_success)) {
         return;
     }
     $method_class = explode('::', $on_success)[0];
     $method = explode('::', $on_success)[1];
     return $method_class::$method(self::$record, $form_config);
 }
Example #2
0
 public function isValid($fields)
 {
     // do validation stuff
     if (!array_key_exists('form_config', $_POST)) {
         return false;
     }
     $form_config = \FormConfig::find($_POST['form_config']);
     if (!\AppLibrary\Obj::iterable($form_config)) {
         return false;
     }
     $is_valid = \Taco\MrSpicy::validate($fields, $form_config);
     $use_ajax = array_key_exists('use_ajax', $_POST) ? true : false;
     if (!$is_valid && $use_ajax) {
         http_response_code(400);
         echo json_encode(array('error' => true, 'message' => $this->error_messages));
         exit;
     } elseif (!$is_valid) {
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * find a form conf taco object in the db
  * @return $this
  */
 private function findFormConfigInstance($conf_name)
 {
     $db_instance = \FormConfig::getOneBy('unique_id', md5($conf_name));
     if (\AppLibrary\Obj::iterable($db_instance)) {
         return $db_instance;
     }
     return false;
 }