/** * do all the validation * @param $record object * @return boolean */ public static function checkSubmission() { // Toggle to $_GET for easy debugging locally $source = $_POST; // Verify we're using a valid Taco class if (!self::isTaco($source)) { return false; } $record = new $source['class'](); self::$record = $record; // Is this an update and not a first time save if (array_key_exists('ID', $source)) { $record = $record::find($source['ID']); } // Is the nonce valid if (!self::isNonceValid($source, $record)) { return false; } // correlate the entry with the form configuration if there is one if (array_key_exists('form_config', $source)) { $record->form_config_id = $source['form_config']; } $validated = self::validateInput($record, $source); if (!$validated) { return false; } $record_info = $validated; // Assign info and save $record->assign($record_info); $entry_id = $record->save(); $record->set('post_title', 'form entry - #' . $entry_id); $record->save(); if (!$entry_id) { return false; } \Taco\MrSpicy::setEntryID($entry_id); self::$form_conf_id = array_key_exists('form_config', $source) ? $source['form_config'] : null; return true; }