public function run($group = '') { $this->set_rules('nonce', 'Nonce', 'required|valid_nonce'); $result = parent::run($group); if($result === true) { $this->save_nonce(); } return $result; }
function run($group = '') { $return = parent::run($group); if ($return === FALSE) { $this->set_js_code(); } return $return; }
public function run($group = '') { // Is there a validation rule for the particular URI being accessed? $uri = $group == '' ? trim($this->CI->uri->ruri_string(), '/') : $group; if ($uri != '' and !isset($this->_config_rules[$uri])) { $this->load_rules_from_database($uri); } return parent::run($group); }
/** * Run * * Validates the CSRF token then runs normal validation. * * @param string The validation group name * @param bool If CSRF tokens should be used * @return bool */ public function run($group = '', $csrf_enabled = TRUE) { log_message('debug', 'My_Form_validation::run() called'); // Do we even have any data to process? Mm? if (count($_POST) == 0) { return FALSE; } if ($csrf_enabled) { $this->_validate_token(); } return parent::run($group); }
function run($group = '') { $rc = FALSE; log_message('DEBUG', 'called MY_form_validation:run()'); if (count($_POST) === 0 and count($_FILES) > 0) { //add a dummy $_POST $_POST['DUMMY_ITEM'] = ''; $rc = parent::run($group); unset($_POST['DUMMY_ITEM']); } else { //we are safe just run as is $rc = parent::run($group); } return $rc; }
public function run($module = '', $group = '') { is_object($module) and $this->CI =& $module; return parent::run($group); }
public function test_run() { // form_validation->run() is tested in many of the other unit tests // This test will only test run(group='') when group is not empty $config = array('pass' => array(array('field' => 'username', 'label' => 'user', 'rules' => 'alpha_numeric')), 'fail' => array(array('field' => 'username', 'label' => 'user', 'rules' => 'alpha'))); $_POST = array('username' => 'foo42'); $form_validation = new CI_Form_validation($config); $this->assertTrue($form_validation->run('pass')); $form_validation = new CI_Form_validation($config); $this->assertFalse($form_validation->run('fail')); }
/** * Performs the actual form validation * * @param string $module Name of the module * @param string $group Name of the group array containing the rules * * @return bool Success or Failure */ public function run($module = '', $group = '') { $this->CI->lang->load('bf_form_validation'); is_object($module) && ($this->CI =& $module); return parent::run($group); }
function run($module = '', $group = '') { (is_object($module)) AND $this->CI =& $module; return parent::run($group); }
public function post() { // Validation result $result = array('validation' => FALSE); // Form name $form_name = $this->input->post('form_name'); // Form settings $form = $this->_get_form_settings($form_name); // Do not validate the form if the form is not defined if (is_null($form)) { $this->xhr_output(array()); } // If rules are defined in the config file... if (isset($form['fields'])) { $fields = $form['fields']; // Get each field settings foreach ($fields as $field => $settings) { if (isset($settings['rules'])) { $rules = $settings['rules']; $label = !empty($settings['label']) ? 'lang:' . $settings['label'] : $field; // See : http://codeigniter.com/user_guide/libraries/form_validation.html#translatingfn $this->form_validation->set_rules($field, $label, $rules); // User's callback rules // Callbacks rules cannot be executed by CI_Form_validation() // They are supposed to be $CI methods and we are here out of the scope of $CI /* * Not implemented for the moment * @todo: execute_validation_callback() needs to be rewritten $rules_array = explode('|', $rules); foreach($rules_array as $rule) { if (substr($rule, 0, 9) == 'callback_') { $row = array( 'field' => $field, 'label' => $label, 'rule' => $rule, 'post' => $this->input->post($field), ); $this->execute_validation_callback($row); } } */ } } // Check the rules $validation_passed = $this->form_validation->run(); // Error if (!$validation_passed) { $result['title'] = lang('form_alert_error_title'); $result['message'] = lang($form['messages']['error']); $result['errors'] = $this->form_validation->_error_array; } else { // Supposed to send back one array with 'title' and 'message' indexes $result = $this->_process_data($form); $result['validation'] = TRUE; if (!isset($result['title']) && !isset($result['message'])) { $result['title'] = lang('form_alert_success_title'); $result['message'] = lang($form['messages']['success']); } } } $this->xhr_output($result); }
function run($module = '', $group = '') { is_object($module) && ($this->CI =& $module); return parent::run($group); }