title: Codeigniter & HMVC - Callback not working
body: <p>I've pretty much gone through a lot of link and solutions provided here and other locations, but I am just not able to solve the callback issue that I am facing. I'm using Codeigniter with HMVC the code is below. </p>
  
  <p>The following code is from <code>My_Form_validation.php</code>:</p>
  
  <p>
  
  <pre><code>class MY_Form_validation extends CI_Form_validation {
  
      function run($module = '', $group = ''){
          (is_object($module)) AND $this-&gt;CI = &amp;$module;
              return parent::run($group);
      }
  }
  </code></pre>
  
  <p>Below if the Callback function :</p>
  
  <pre><code>public function _unique_email($str) {
  
      // Check if user already exists
      // Process only for current user
      $id = $this-&gt;uri-&gt;segment(4);
      $this-&gt;db-&gt;where('email', $this-&gt;input-&gt;post('email'));
      !$id || $this-&gt;db-&gt;where('id !=', $id);
      $user = $this-&gt;mdl_admin_users-&gt;get();
  
      if (count($user)) {
          $this-&gt;form_validation-&gt;set_message('_unique_email', 'User already exists. Please check %s.');
          return FALSE;
      }
  
      return TRUE;
  }
  </code></pre>
  
  <p>and the function :</p>
  
  <pre><code>public function user_edit($id = NULL) {
  
      // Fetch a user or set a new one
      if ($id) {
          $data['user'] = $this-&gt;mdl_admin_users-&gt;get($id);
          count($data['user']) || $data['errors'][] = 'User could not be found';
      }
      else {
          $data['user'] = $this-&gt;mdl_admin_users-&gt;get_new();
      }
  
      // setup the form
      $rules = $this-&gt;mdl_admin_users-&gt;rules_admin;
      $id || $rules['password'] = '|required';
      $this-&gt;form_validation-&gt;set_rules($rules);
  
      //process the form
      if ($this-&gt;form_validation-&gt;run($this) == TRUE) {
          $data = $this-&gt;mdl_admin_users-&gt;array_from_post(array('firstname', 'lastname', 'email', 'password'));
          $data['password'] = $this-&gt;mdl_admin_users-&gt;hash($data['password']);
          $this-&gt;mdl_admin_users-&gt;save($data, $id);
          redirect('admin/user');
      }
  
      // Load the view
      $data['title'] = 'Edit Users';
      $data['module'] = 'admin';
      $data['header_file'] = 'header_admin';
      $data['nav_file'] = 'nav_admin';
      $data['view_file'] = 'edit_users';
      $data['footer_file'] = 'footer_admin';
      echo Modules::run('template/base_template', $data);
  
  }
  </code></pre>
  
  <p>Would be a great help if someone could point me at the right direction to resolve the issue. Thanks in advance</p>
  
  <p>Naveen</p>