![]() |
How to run validation and controller logic in one function? - 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: How to run validation and controller logic in one function? (/showthread.php?tid=59098) |
How to run validation and controller logic in one function? - El Forum - 08-23-2013 [eluser]RaGe10940[/eluser] So I am trying to be as "lazy" as possible when it comes to the amount of code I can write. Usually my controller would look like so : Code: public function index() {// Load login page that is to load the view and then another function to accept the form like so : Code: public function login_user() { Now what I am trying to do is condense this into one method but I keep getting stuck in a loop after my validation error returns FALSE. does any one have any work arounds for this? Code: public function index() {// Load login page How to run validation and controller logic in one function? - El Forum - 08-23-2013 [eluser]jairoh_[/eluser] after loading the library, set some rules like Code: $this->form_validation->set_rules('username', 'Username', 'required'); Code: if ( $this->form_validation->run() == FALSE ) { How to run validation and controller logic in one function? - El Forum - 08-23-2013 [eluser]M Arfan[/eluser] Code: public function login() { that should help you |