Set form action in Laravel 5
In this tutorial I will help you to set form action in laravel 5 or laravel 5.4. if you using blade template for show a form in you laravel project, so it’s will be helpful for you.
Set form URL in Laravel 5 like that:
{{Form::open(array('url'=>'sign_up'))}} <input type="text" name="name" class="form-control"> {{Form::close()}}
When you insert data into the database then you must set the form method. You can use the POST method for pass the form value in the controller or model page. Everyone are know that the POST method transfers user information via HTTP headers. So use POST method like that:
{{Form::open(array('url'=>'sign_up','method'=>'post','class'=>'form-login'))}} {{Form::close()}}
After use form tag using blade in laravel 5 or laravel 5.4, then you can use the HTML text field or create input field using blade and set class or value or placeholder in a array.
That’s like:
{{Form::text('name', null, array( 'class'=>'form-control', 'placeholder'=>'Your name')) }}
Or use it
{!! Form::text('name', null, array( 'class'=>'form-control', 'placeholder'=>'Your name')) !!}
If you set in a text field require or read only, so use this code:
{{Form::text('name', null, array('required', 'class'=>'form-control', 'placeholder'=>'Your name')) }}
Or
{!! Form::text('name', null, array('required', 'class'=>'form-control', 'placeholder'=>'Your name')) !!}