![]() |
validation and pass an id in url to view from controller - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: validation and pass an id in url to view from controller (/showthread.php?tid=68047) |
validation and pass an id in url to view from controller - Ali - 05-15-2017 Hello sorry for my bad english. i really need help ![]() i am creating a simple help desk and i have one question please answer me. 1: go to new ticket ( ex: localhost/helpdesk/index.php/ticket/show/10 ). for number 1 i have a function ( public show ) and display all replies in id 10. 2: and show/10 has a form for reply your comment. ( screenshot : http://s6.uplod.ir/i/00880/op3jnntpy1lu.jpg ) then i need validation form when users submit new reply. i wrote validation rules, but i can't pass message error from controller to view (ticket/show/id). PHP Code: public function show() PHP Code: public function reply() RE: validation and pass an id in url to view from controller - neuron - 05-15-2017 in Codeigniter best practice is to put form_validation in the same method. I mean you should merge your show() and reply() methods PHP Code: public function show($groups_id) To show errors in view : PHP Code: <?php echo form_error('field name', '<div class="error">', '</div>'); ?> Try this way, if this does not help, post your view code also. RE: validation and pass an id in url to view from controller - Ali - 05-15-2017 please more explain. i have problem in reply function RE: validation and pass an id in url to view from controller - neuron - 05-15-2017 PHP Code: public function show($groups_id) RE: validation and pass an id in url to view from controller - Ali - 05-16-2017 could you have a look my view PHP Code: <section class="panel"> RE: validation and pass an id in url to view from controller - neuron - 05-16-2017 if u used my posted code, there is no reply() method in my code, so you have to set your form action in to PHP Code: echo form_open_multipart('ticket/show' . $groupsId ); after fixing it, when u post form with empty inputs you should see form validation errors RE: validation and pass an id in url to view from controller - Ali - 05-16-2017 A PHP Error was encountered Severity: Notice Message: Undefined variable: id Filename: controllers/ticket.php Line Number: 115 Backtrace: File: C:\wamp\www\ticket\application\controllers\ticket.php Line: 115 Function: _error_handler File: C:\wamp\www\ticket\index.php Line: 315 Function: require_once |