mardi 26 septembre 2017

Return back from edit form after several updates in Laravel 5.4

I'm trying to add functionality to my edit form. Perhaps not a best practice but...

I want to keep the original url for several updates. When a user first lands on edit form (from list or single view) I want a Cancel button that redirects user back to.. "referrer". After an update I redirect back to edit form with success message. I want to hide the Cancel button and show Back button. User can edit multiple times.

I tried to pass the original url through Request, but that didn't end well. Now I'm trying with storing the url in session. Ifs work, but the session item value gets overwritten in second iteration.

Perhaps I'm using the session the wrong way? Any idea? Perhaps another "better" way?

The code in my edit.blade

@if(url()->current() != URL::previous())
    @if(Session::has('myreferrer'))
        
    @endif
    
    <a href="" class="btn">Cancel</a>
@else
<a href="" class="btn">Back</a>
@endif



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire