Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to create forms in Laravel 5.4?

What is the easiest, most elegant and effective way to create forms with Blade in Laravel 5.4? I'm creating an application with many forms and most of the fields look the same:

<label for="name">Name:</label>
<input type="text" name="name" id="name" value="{{ old('name') }}">

@if ($errors->has('name'))
<ul>
    @foreach($errors->get('name') as $error)
    <li>{{ $error }}</li>
    @endforeach
</ul>
@endif

So I wonder if there is any built-in mechanism to generate forms easily?

Thanks

like image 732
Martin Heralecký Avatar asked Feb 05 '17 12:02

Martin Heralecký


People also ask

What is Form Builder in laravel?

Laravel Form Builder is a package by Kristijan Husak that incorporates an API similar to Symfony's form builder for Laravel 5 applications. Form builder for Laravel 5 inspired by Symfony's form builder. With the help of Laravels FormBuilder class creates forms that can be easily modified and reused.

What is laravel collective form?

The Laravel Collective package HTML comes packed with an HTML and FORM generator allowing you to handle easy to manage forms in your blade files as well as intricate model binding to your forms.


1 Answers

  1. You can use the Laravel Collective Forms & HTML Package for form model binding and generating fields
  2. For displaying errors, you can use sub-views
like image 72
Paras Avatar answered Sep 19 '22 19:09

Paras