change form route laravel 5.4 with jquery

0

I have the following form in a view:

{!! Form::open(['route'=>['user.update',$user_id], 'method' => 'PUT']) !!}
{{ Form::close() }}

How can I assign the value of 'user_id' dynamically with jquery?

This is the HTML that generates the form with blade, where the 'X' is user_id

 <form method="POST" action="http://127.0.0.1:8000/public/user/X" 
  accept-charset="UTF-8" id="form_edit">

 <input name="_method" type="hidden" value="PUT"><input name="_token" 
  type="hidden" value="UlVvrYf77puFKb5XQutbIZBIqDSaA7F8n9s8D31k">
    
asked by Renato 09.11.2017 в 17:20
source

1 answer

0

If you are going to change the% tribute% of action it is best to put an id to your from and edit the form

{!! Form::open(['route'=>['user.update',$user_id], 'method' => 'PUT','id'=>'form_action']) !!}

and using jquery or javascript access and modify the attribute. But placing the base url that gives you laravel with the function action

$('#form_edit').attr('action', '{{url('')}}/public/user/'+user_id);

This is how you should solve your problem.

Try it and tell us how it went.

Greetings.

    
answered by 09.11.2017 / 18:56
source