Aire Form Builder Package for Laravel
Published on by Paul Redmond
Aire is a Laravel form builder package by Chris Morrell with features like data binding and an expressive syntax:
Aire is a modern Laravel form builder (demo) with a focus on the same expressive and beautiful code you expect from the Laravel ecosystem.
Here’s a basic demo from the project’s readme:
{{ Aire::open()->route('users.update') }} {{ Aire::bind($user) }} <div class="flex flex-col md:flex-row"> {{ Aire::input('given_name', 'First/Given Name') ->id('given_name') ->autoComplete('off') ->groupClass('flex-1 mr-2') }} {{ Aire::input('family_name', 'Last/Family Name') ->id('family_name') ->autoComplete('off') ->groupClass('flex-1') }} </div> {{ Aire::email('email', 'Email Address') }} {{ Aire::submit('Update User') }} {{ Aire::close() }}
I like data binding features that typically come with form builder libraries which make it simple to map a model to form inputs. The data binding also takes care of populating form inputs with old()
data when validation errors occur.
The Aire package includes Eloquent model binding along with the ability to bind custom array/object data:
// Bind Eloquent modelsAire::bind(User::find(1)); // Bind an arrayAire::bind(['given_name' => 'Chris']); // Bind any objectAire::bind((object) ['given_name' => 'Chris']);
If data binding was not enough, this package also automatically picks up any errors and applies error classes and shows error messages with the associated input. Also, you have access to a summary of error messages with the following methods:
// Print "There are X errors on this page that you must fix before continuing."{{ Aire::summary() }} // Also include an itemized list of errors{{ Aire::summary()->verbose() }}
To get started with the Aire Form Builder package, head over to the Documentation & Demos. You can view the source code on GitHub at glhd/aire.