[eluser]Pintossauro[/eluser]
Hi all,
In my application i have Projects that can have Tasks. I created a form to add a Task in a Project. I also configured routes.php:
Code:
$route['([0-9]+)/tasks/add'] = "task/add/$1";
(the first argument is the project id) and i have a link in the projects page:
Code:
anchor($project_id.'/tasks/add', 'Add new task')
With this the user will be redirected to my <b>add($project_id)</b> function in my Task controller which will load the 'task/add' view with the correspondent project information and the form to add the new task (the url in the browser will still be, e.g., "4/tasks/add").
Then when the user submits his information i have a function <b>"insert_task"</b> in my Task controller that validates the data.
If all OK insert data in the database and load the view with the list of tasks in the project. If not i wanted the user to see
the <b>'4/tasks/add'</b> view again with the errors but if i do <b>$this->load->view('task/add')</b> like i did in my function "add" the url will be <b>.../index.php/task/insert_task </b> and not <b>../index.php/4/tasks/add</b> as i wanted.
Maybe i'm not understanding the MVC pattern correctly or am i using two functions (add - to load the form view - and insert_task - to validate and insert the task in
the DB) when not necessary.
Does someone have an suggestion how to solve this?
Thanks for your attention,
Pintossauro.