Welcome Guest, Not a member yet? Register   Sign In
How to handle two submit buttons with two destinations ?
#1

[eluser]Dagobert Renouf[/eluser]
Hello everyone.

I have a form that displays all my articles with a checkbox next to each one, so the user can select a bunch of them to edit or delete them.
The fact is a form can only have one action destination, so if I set the delete destination => edit won't load, and If i set the edit action => delete won't load.

So what I'm asking is : how can I handle this right ?
#2

[eluser]wiredesignz[/eluser]
Its all edit action, make delete a function of edit.
#3

[eluser]Dagobert Renouf[/eluser]
thanks a lot wiredesignz that's so simple.
Now I handled the delete action on the edit function, but I'm still trying to handle the edit function by itself !

I'm totally messed up with the idea of displaying all fields of editable articles at the same time and in the same form.
How would some php guru do (I just need the logic) to display a certain amount of "edit" form withs - for each specific form - the data's already field in ?
#4

[eluser]louis w[/eluser]
Use one destination but name them differently.

Code:
<input type="submit" name="do_edit" value="EDIT" />
<input type="submit" name="do_delete" value="DELETE" />

The value for the button will only get submitted for the one you click on.
Then in your controller test against it:

Code:
if ($this->input->post('do_delete') == 'DELETE') {
    // DELETE
} if ($this->input->post('do_edit') == 'EDIT' {
    // EDIT
} else {
    // WHOOPS
}
#5

[eluser]Dagobert Renouf[/eluser]
thanks a lot louis w.
Sadly, I already handled that :-D. But your answer confirm the way I did, that's the exact same code ;-).

Now I'm seeking help to handle validation on multiple fields at the same time, would you have any thought ? I'm hoping for a guru to help me out, that's tough.




Theme © iAndrew 2016 - Forum software by © MyBB