Codeigniter Course Of Written Report Validation Set_Value Too Set_Checkbox Work Fixed
For example, I bring 2 fields inwards my shape first_name together with last_name
I bring prepare the validation dominion exclusively for first_name. 'set_value' should piece of work for both the fields regardless of dominion ? Right ?
- No, set_value or set_checkbox or set_select exclusively plant against the items y'all bring chosen to validate using the form_validation class.
Solution
Simple trend to cook this work is to overwrite the center 'MY_form_helper.php' amongst roughly functions.
- Copy the next code together with relieve it together with cite it equally 'My_form_helper.php' together with placed nether 'application/helpers' folder. It volition overwrite the center functions.
Enjoy :)
Source: http://pastebin.com/h70F9esF Sumber http://developer-paradize.blogspot.com
I bring prepare the validation dominion exclusively for first_name. 'set_value' should piece of work for both the fields regardless of dominion ? Right ?
- No, set_value or set_checkbox or set_select exclusively plant against the items y'all bring chosen to validate using the form_validation class.
Solution
Simple trend to cook this work is to overwrite the center 'MY_form_helper.php' amongst roughly functions.
- Copy the next code together with relieve it together with cite it equally 'My_form_helper.php' together with placed nether 'application/helpers' folder. It volition overwrite the center functions.
<?php if ( ! defined('BASEPATH')) exit('No straight script access allowed'); /** * Form Value * * Grabs a value from the POST array for the specified champaign then y'all tin * re-populate an input champaign or textarea. If Form Validation * is active it retrieves the information from the validation degree * * @access populace * @param string * @return mixed */ if (!function_exists('set_value')) { role set_value($field = '', $default = '') { $OBJ = & _get_validation_object(); if ($OBJ === TRUE && isset($OBJ->_field_data[$field])) { provide form_prep($OBJ->set_value($field, $default)); } else { if (!isset($_POST[$field])) { provide $default; } provide form_prep($_POST[$field]); } } } if (!function_exists('set_checkbox')) { role set_checkbox($field = '', $value = '', $default = '') { $OBJ = & _get_validation_object(); if ($OBJ === TRUE && isset($OBJ->_field_data[$field])) { provide form_prep($OBJ->set_checkbox($field, $value, $default)); } else { if (!isset($_POST[$field])) { provide ''; } else{ if($_POST[$field] == $value) { provide 'checked=\'checked\''; } } } } } /* End of file MY_form_helper.php */ /* Location: ./application/helpers/MY_form_helper.php */This volition overwrite the center functions MY_form_helper.php together with volition piece of work amongst all the fields regardless of validation rules.
Enjoy :)
Source: http://pastebin.com/h70F9esF Sumber http://developer-paradize.blogspot.com
Comments
Post a Comment