Welcome Guest, Not a member yet? Register   Sign In
A "User's Guide" to Jamie Rumbelow's MY_Model library
#5

[eluser]Mauricio de Abreu Antunes[/eluser]
IMHO, validation must to be in controllers.
MY_Model has a validation config.
How can i return error messages in Model?

I was thinking:
1 - Create a config like
Code:
//$config_validation[your_table][field]
$config_validation['news']['title'] =
array('title', 'Title', 'required|xss|min_length[25]|max_length[100]');
$config_validation['news']['tag']    =
array('tag', 'News Tag', 'xss|min_length[1]|max_length[20]');

2 - Create a method in MY_Controller:
Code:
public function checkValidation ($table, $arr_fields) {
//Loop array with table ($table) index checking fields and setting validation
foreach ($arr_fields as $f) {
  $this->form_validation->set_rules($config_validation[$table][$f][0], $config_validation[$table][$f][1], $config_validation[$table][$f][2]);
}
}
Did you get my point?

PS.: i did not check my code, just for show my ideas!


Messages In This Thread
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 01-13-2012, 11:36 PM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 03-01-2012, 11:53 AM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 03-01-2012, 12:09 PM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 03-01-2012, 12:30 PM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 03-01-2012, 01:33 PM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 04-24-2012, 11:24 PM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 04-25-2012, 12:02 AM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 05-03-2012, 09:52 PM
A "User's Guide" to Jamie Rumbelow's MY_Model library - by El Forum - 05-03-2012, 10:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB