CodeIgniter Forums
Undefined property: News::$form_validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Undefined property: News::$form_validation (/showthread.php?tid=55150)



Undefined property: News::$form_validation - El Forum - 10-12-2012

[eluser]rm_beginner[/eluser]
Hi All,

Pls help i am new in this php coding. When i follow the tutorial
I received this error message:


"A PHP Error was encountered

Severity: Notice

Message: Undefined property: News::$form_validation

Filename: controllers/news.php

Line Number: 45

Fatal error: Call to a member function set_rules() on a non-object in .../application/controllers/news.php on line 45"


line 45: $this->form_validation->set_rules('title', 'Title', 'required');


Thanks.



Undefined property: News::$form_validation - El Forum - 10-12-2012

[eluser]alexwenzel[/eluser]
You forgot to load the form validation library. Load it either with autoload.php or with CI loader class.


Undefined property: News::$form_validation - El Forum - 10-17-2012

[eluser]rm_beginner[/eluser]
Hi,

Thanks for the reply.

can you try this tutorial?
here's the link: http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html

it was loaded here...

Code:
<?php

class Form extends CI_Controller {

function index()
{
  $this->load->helper(array('form', 'url'));

  $this->load->library('form_validation'); //<---------loaded.

  if ($this->form_validation->run() == FALSE) //<---the error is here.
  {
   $this->load->view('myform');
  }
  else
  {
   $this->load->view('formsuccess');
  }
}
}
?&gt;


Fatal error: Call to a member function run() on a non-object in ../application/controllers/form.php on line 11



Thank you.


Undefined property: News::$form_validation - El Forum - 10-17-2012

[eluser]CroNiX[/eluser]
Maybe you need to set some validation rules first before you run it.


Undefined property: News::$form_validation - El Forum - 10-22-2012

[eluser]rm_beginner[/eluser]
I solved it again..Smile

just put in autoload.php and remove the load command in form controller.

thanks