Pass variable in url on form submit |
[eluser]Wonder Woman[/eluser]
Hi, I have an edit url set up so that the article id is appended on the end, however when I got to submit the form it doesn't work because I can't append this variable on the end. View: Code: echo anchor('admin/pages/edit/'.$page->id, 'Edit'); Controller: function edit($page_id) Code: { How can I do it so that the page will submit and go back to 'admin/pages/edit/1', for example. Many thanks in advance.
[eluser]d1a8lo24[/eluser]
Use the $page_id var and append/concatenate like you did in the anchor function in the redirect() Code: redirect('admin/pages/edit' . $page_id, $data);
[eluser]Wonder Woman[/eluser]
I have tried that but it doesn't work, my browser says there is a problem loading the page.
[eluser]d1a8lo24[/eluser]
Quick notice i guess you're using javascript to submit otherwise an anchor/link will not work to subit a form you need a form_open() and a form_close() thing. More under http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]d1a8lo24[/eluser]
Sorry i miss the '/' Now try it again Code: redirect('admin/pages/edit/' . $page_id, $data);
[eluser]d1a8lo24[/eluser]
Quick question do you have index function and are you using that to submit to the edit function in the same controller?
[eluser]Wonder Woman[/eluser]
I have an initial view, pages.php: Code: anchor('admin/pages/edit/'.$page->id, 'Edit').' '.anchor($page->url, 'View'); This then takes you to my edit page: Code: echo form_open(); This is the edit function in the controller: Code: function edit($page_id) Hope this makes sense...
[eluser]d1a8lo24[/eluser]
Ok sorry on your redirect you can't pass any data more info here http://ellislab.com/codeigniter/user-gui...elper.html
[eluser]d1a8lo24[/eluser]
Also if you were using the session to see if the page id was being past you can remove it. If you were trying to pass that id then you don't need to put it in the array data since you already set in the session just use the session class to output the result in your view. |
Welcome Guest, Not a member yet? Register Sign In |