Welcome Guest, Not a member yet? Register   Sign In
HMVC and form_validation.php?
#7

[eluser]Steve Goodwin[/eluser]
thanks for your replies, I have done all of this, I've been using this setup for a while now just trying to improve it.

My code is as follows:

MY_Controller:

Code:
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

/* load the MX_Loader class */
require APPPATH."libraries/MX/Controller.php";

class MY_Controller extends MX_Controller
{
    function __construct()
    {
        parent::__construct();

        $this->form_validation->CI =& $this;
    }
}

Admin_Controller:

Code:
class Admin_Controller extends MY_Controller {

public function __construct()
{
  parent::__construct();

        //  Load Libraries
        $this->load->library('ion_auth');

        //  Check if user is logged in?
        if (!$this->ion_auth->logged_in())
        {
            //redirect them to the login page
            redirect('admin/login', 'refresh');
        }
}

}

The my module is structured like this:

- modules
- test
- config
- routes.php
- form_validation.php
- controllers
- test.php
- models
- test_m.php
- views
- add.php
- edit.php
- view.php
- delete.php

My HMVC setup is as follows:

My_Form_validation.php

Code:
class MY_Form_validation extends CI_Form_validation
{
    public $CI;
}

My Config / form_validation.php file setup is:

Code:
$config = array(
    'test/add' => array(
        array(
            'field'   => 'uri',
            'label'   => 'URI',
            'rules'   => 'required|trim|xss_clean|is_unique[uri_tbl.uri]'
        ),
        array(
            'field'   => 'title',
            'label'   => 'Title',
            'rules'   => 'required|trim|xss_clean'
        ),
        array(
            'field'   => 'description',
            'label'   => 'Description',
            'rules'   => 'required|trim|xss_clean'
        )
    ),
    'test/edit' => array(
        array(
            'field'   => 'title',
            'label'   => 'Title',
            'rules'   => 'required|trim|xss_clean'
        ),
        array(
            'field'   => 'description',
            'label'   => 'Description',
            'rules'   => 'required|trim|xss_clean'
        )
    )
);

The function within my controller is as follows:

Code:
public function add()
    {
        // Validate the page
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('add');
        }
        else
        {
            redirect('/test/view');
        }
    }

As you can see everythings setup "as per the guides, topics on the forums and known issues".

I'm posting this because form_validation.php isn't loading at all, the tests i've done are:

- Normal $this->form_validation->set_rules('uri', 'URI', 'required|trim|xss_clean'); and this works.
- I've tested callbacks and they work as well with no trouble.
- When testing the form validation within the form_validation.php file located in /modules/test/config/form_validation.php this fails. I know this isn't loading due to inserting a simple echo "FORM VALIDATION LOADED"; snippet at the top and nothing printing out on the screen.

Any suggestions as to why this feature isn't working? I've read all documentation and instructions before coming to this forum to save basic answers that would point to me being lazy and not reading or googling for existence of this problem currently.


Messages In This Thread
HMVC and form_validation.php? - by El Forum - 08-08-2012, 06:54 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 09:22 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 09:33 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 09:54 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 10:36 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 10:38 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 10:56 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 11:14 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 11:15 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 11:54 AM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 12:42 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 12:49 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 12:57 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 01:09 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 01:13 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 01:32 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 03:16 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 03:19 PM
HMVC and form_validation.php? - by El Forum - 08-08-2012, 06:09 PM
HMVC and form_validation.php? - by El Forum - 08-09-2012, 02:32 AM



Theme © iAndrew 2016 - Forum software by © MyBB