Welcome Guest, Not a member yet? Register   Sign In
Issue with Form Validation library
#1

[eluser]cayasso[/eluser]
Hi All,
I am running into a problem here with CI and form validation and I was hoping
that some one can help me out or point me to the right path. Its been 2 day now
trying to get a solution but still I haven't get one. I have read some other post but cannot find an answer.

It seems that you cannot use form_validation library from a controller that
extends from another controller.
Call to a member function load() on a non-object in
C:\wamp\www\lx2\system\libraries\Form_validation.php on line 316

Can you please help me out in a way of how to load and use form_validation on a
child controller.

Thank you very much and I will really appreciate your help this is very
important for me I am delivering a system :|



I have created a page base controller in application/libraries, this controller has all the funcionality to build the page layout itself.

Code:
class MY_Controller extends Controller
{
function __construct()
{
parent::Controller()
}

function index()
{
//...General code to create a page
}
}

and I have in application/controllers/Comments.php

Code:
class Comments extends MY_Controller
{
function __construct()
{
     parent::__construct();
     $this->load->helper('form');
     $this->load->library('form_validation');
}

function index()
{
    $this->form_validation->set_rules('db_name', 'Username', 'required');
    $this->form_validation->set_rules('db_email', 'Email', 'required');

if($this->form_validation->run() == FALSE)
{
     echo 'FORM IS NOT VALID CHECK BELLOW';
     echo '<h1>'.validation_errors().'</h1>';
}else{
     echo 'YOU ARE SUBMITTING A VALID FORM';
}


     echo form_open('comments');
     echo form_label('Name ', 'name');
     echo form_input(array(
             'name' => 'db_name',
             'size' => '50',
             'maxlength' => '255',
             'value' => 'hay muchos valores en esta caja'
         )).'<br />';

     echo form_label('Email ', 'email');
     echo form_input(array(
             'name' => 'db_email',
             'size' => '50',
             'maxlength' => '255',
             'value' => 'hay muchos valores en esta caja'
         )).'<br />';
     echo form_submit('', 'Submit', 'class="submit"');
     echo form_close();
}
}


Messages In This Thread
Issue with Form Validation library - by El Forum - 11-10-2008, 03:32 PM
Issue with Form Validation library - by El Forum - 11-10-2008, 05:53 PM



Theme © iAndrew 2016 - Forum software by © MyBB