Support the ongoing development of Laravel.io →
Forms Validation

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 :(

Last updated 3 years ago.
0

You need to use javascript to redirect. This doesn't work on mine too. Anyone?

0

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?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

narfed narfed Joined 5 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.