当前位置: 首页>>代码示例>>PHP>>正文


PHP CI_Form_validation::set_rules方法代码示例

本文整理汇总了PHP中CI_Form_validation::set_rules方法的典型用法代码示例。如果您正苦于以下问题:PHP CI_Form_validation::set_rules方法的具体用法?PHP CI_Form_validation::set_rules怎么用?PHP CI_Form_validation::set_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CI_Form_validation的用法示例。


在下文中一共展示了CI_Form_validation::set_rules方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_rules

 public function set_rules($field, $label = '', $rules = '')
 {
     if (is_array($field)) {
         foreach ($field as $row) {
             if (!isset($row['field']) or !isset($row['rules'])) {
                 continue;
             }
             $label = !isset($row['label']) ? $row['field'] : $row['label'];
             return $this->set_rules($row['field'], $label, $row['rules']);
         }
     }
     if (!is_string($field) or !is_string($rules) or $field == '') {
         return $this;
     }
     foreach (explode('|', $rules) as $rule) {
         if (strpos($rule, '[') !== FALSE) {
             $rule = current(explode('[', $field));
         }
         if (in_array($rule, $this->_rules)) {
             if (FALSE === ($line = $this->CI->lang->line($rule))) {
                 $line = 'Unable to access an error message corresponding to your field name.';
             }
             $this->rule_messages[$rule] = $line;
         }
     }
     $label = $label == '' ? $field : $label;
     $this->js_rules[] = array('name' => $field, 'display' => $label, 'rules' => $rules);
     return parent::set_rules($field, $label, $rules);
 }
开发者ID:navruzm,项目名称:navruz.net,代码行数:29,代码来源:MY_Form_validation.php

示例2: set_rules

 /**
  *@desc Allow set a custom validation error message
  *
  */
 public function set_rules($field, $label = '', $rules = '', $message = '')
 {
     $rules = parent::set_rules($field, $label, $rules);
     if (!empty($message)) {
         $this->_custom_field_errors[$field] = $message;
     }
     return $rules;
 }
开发者ID:anhoale,项目名称:codeigniter-cms,代码行数:12,代码来源:MY_Form_Validation.php

示例3: set_rules

 public function set_rules($input_name, $input_name_display, $rule = NULL)
 {
     if ($rule == NULL) {
         $rule = $input_name_display;
         parent::set_rules($input_name, $input_name, $rule);
     } else {
         parent::set_rules($input_name, $input_name_display, $rule);
     }
 }
开发者ID:piranon,项目名称:gae,代码行数:9,代码来源:MY_Form_validation.php

示例4: unset

 function set_rules($field, $label = '', $rules = '')
 {
     if (count($_POST) === 0 and count($_FILES) > 0) {
         //add a dummy $_POST
         $_POST['DUMMY_ITEM'] = '';
         parent::set_rules($field, $label, $rules);
         unset($_POST['DUMMY_ITEM']);
     } else {
         //we are safe just run as is
         parent::set_rules($field, $label, $rules);
     }
 }
开发者ID:amenski,项目名称:BookSharing,代码行数:12,代码来源:code.php

示例5: array

 function set_rules($field, $label = '', $rules = array(), $errors = array())
 {
     if (count($_POST) === 0 and count($_FILES) > 0) {
         //it will prevent the form_validation from working
         //add a dummy $_POST
         $_POST['DUMMY_ITEM'] = '';
         parent::set_rules($field, $label, $rules);
         unset($_POST['DUMMY_ITEM']);
     } else {
         //we are safe just run as is
         parent::set_rules($field, $label, $rules);
     }
 }
开发者ID:DeDoOozZz,项目名称:sales,代码行数:13,代码来源:Brightery_form_validation.php

示例6: set_rules

 public function set_rules($field, $label = '', $rules = '')
 {
     // No reason to set rules if we have no POST data
     if (count($_POST) == 0) {
         return $this;
     }
     if (is_array($field) && $field !== array_values($field)) {
         foreach ($field as $key => $value) {
             $label = !empty($value[1]) ? $value[1] : humanize($key);
             parent::set_rules($key, $label, $value[0]);
         }
         return $this;
     }
     parent::set_rules($field, $label, $rules);
 }
开发者ID:rip-projects,项目名称:ark-php,代码行数:15,代码来源:MY_Form_validation.php

示例7: set_rules

 /**
  * Set Rules
  *
  * This function takes an array of field names and validation
  * rules as input, any custom error messages, validates the info,
  * and stores it
  *
  * @param	mixed	$field
  * @param	string	$label
  * @param	mixed	$rules
  * @param	array	$errors
  * @return	CI_Form_validation
  */
 public function set_rules($field, $label = '', $rules = array(), $errors = array())
 {
     $this->request_method = $this->CI->input->method();
     return parent::set_rules($field, $label, $rules, $errors);
 }
开发者ID:maltyxx,项目名称:restserver,代码行数:18,代码来源:MY_Form_validation.php

示例8: set_rules

 public function set_rules($field, $label = '', $rules = '')
 {
     $this->_add_field_name($field);
     parent::set_rules($field, $label, $rules);
 }
开发者ID:anupkelkar02,项目名称:FSM,代码行数:5,代码来源:MY_Form_validation.php

示例9: post

 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);
 }
开发者ID:trk,项目名称:ionize,代码行数:66,代码来源:ajaxform.php


注:本文中的CI_Form_validation::set_rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。