Search code examples
laravellaravel-5laravel-5.3

Posting multiple modals on the same page


I have multiple modal windows to edit the user profile in my Laravel app. A modal to edit the description, one to edit Hobbies and so on. Using one modal works fine because I can post it to the profile page but the thing is, I want to post all modals to the same page and that's why is not working, I'm aware of this.

Here's what I mean:

  Route::put('/user/profile/edit','UserController@putDesc');
  Route::put('/user/profile/edit','UserController@putRate');

The modals are pretty basic forms where I set up the action to point to UserController method. How should I make the routing in this case? I hope I was clear.


Solution

  • Route::put('somelink', ['uses' => 'SomeController@someFunction', 'as' => 'one-route');
    Route::put('someolink', ['uses' => 'SomeController@someOtherFunction', 'as' => 'two-route');
    

    etc.

    And into your view if you are using LaravelCollective you can do this like that:

    {!! Form::open(['method' => 'POST', 'route' => 'one-route']) !!}
    {!! Form::close() !!}
    
    {!! Form::open(['method' => 'POST', 'route' => 'two-route']) !!}
    {!! Form::close() !!}
    

    If you are not using LaravelCollective put into action attribute

    {{route('one-route')}} or {{route('two-route')}}