Permalink
Browse files

moved validation array to the model

  • Loading branch information...
1 parent 6eb8647 commit 16617fd61e877ff546882047e0712d2bc874fa33 @rpnzl committed May 18, 2012
Showing with 21 additions and 22 deletions.
  1. +2 −22 controllers/admin.php
  2. +19 −0 models/slider_m.php
View
@@ -10,26 +10,6 @@ class Admin extends Admin_Controller {
protected $section = 'sliders';
- /**
- * Array that contains the validation rules
- *
- * @access protected
- * @var array
- */
- protected $_validation_rules = array(
- array(
- 'field' => 'jquery',
- 'label' => 'jQuery',
- 'rules' => 'trim|required|numeric'
- ),
- array(
- 'field' => 'folder_id',
- 'label' => 'Folder',
- 'rules' => 'trim|required|numeric'
- ),
- );
-
-
public function __construct()
{
parent::__construct();
@@ -40,7 +20,7 @@ public function __construct()
$this->load->model(array('slider_m', 'files/file_folders_m',));
// set validation rules
- $this->form_validation->set_rules($this->_validation_rules);
+ $this->form_validation->set_rules($this->slider_m->_validation_rules);
// template settings
$this->template->title($this->module_details['name']);
@@ -72,7 +52,7 @@ public function index()
}
// loop through each validation rule
- foreach ($this->_validation_rules as $rule)
+ foreach ($this->slider_m->_validation_rules as $rule)
{
$slider_m->{$rule['field']} = set_value($rule['field']);
}
View
@@ -7,6 +7,25 @@
class Slider_m extends MY_Model
{
/**
+ * Array that contains the validation rules.
+ *
+ * @access public
+ * @var array
+ */
+ public $_validation_rules = array(
+ array(
+ 'field' => 'jquery',
+ 'label' => 'jQuery',
+ 'rules' => 'trim|required|numeric'
+ ),
+ array(
+ 'field' => 'folder_id',
+ 'label' => 'Folder',
+ 'rules' => 'trim|required|numeric'
+ ),
+ );
+
+ /**
* Get Sliders Module settings.
*
* Takes the work out of grabbing the settings whenever

0 comments on commit 16617fd

Please sign in to comment.