This works if there has been no attempt to update the record and the user just clicks cancel.
{{Form::submit('Update',array('class'=>'btn btn-success'))}}
<a href = "{{URL::previous()}}" class = 'btn btn-warning'>Cancel</a>
But if they try to update and get sent back to the edit page from the edit page, the cancel button will return to the edit page and go nowhere.
Seems like a common thing to have a cancel button on forms... but how, all the tutorials and references don't include a cancel button to show how this is done :(
You need to use javascript to redirect. This doesn't work on mine too. Anyone?
The previous() method just gives you the last URL. On the first load this is obviously the page the user came from but after you've submitted your form this is the previous "form page" (because a request happened in between).
I'd say you have to put a real url on the cancel button. Are there multiple pages from which you can access your form?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community