Download the PHP package aracademia/lightning without Composer
On this page you can find all versions of the php package aracademia/lightning. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aracademia/lightning
More information about aracademia/lightning
Files in aracademia/lightning
Package lightning
Short Description Create Laravel forms with a single line of code
License MIT
Informations about the package lightning
Lightning Laravel Forms
=========
Create Laravel forms with a single line of code
Installation ( using composer )
- Add the code below to your
composer.json
file
-
Run Composer update in your terminal
-
Add the service provider below to
app/config/app.php
under theproviders
array - Publish the config file by running the command below in your terminal. After that the config file will be placed under
app/config/packages/aracademia/lightning
How to use the package
Let's use an example to see how easy this package is. We are going to create a contact us form.
open a view file, make sure it has .blade.php
extension, then enter the following code
That's it. These three words will create a contact us form with the following fields: First Name, Last Name, Email, Message, Submit button using bootstrap styling, and the post url will be the current page url by default.
If you would like to create a login form, then all you have to do is change the name contact to login
That will create a login form with email and password fields.
Ok, that's cool... but wait a minute! what if I want to add other fields or maybe edit the existing fields? what if I want to add attributes to my fields or override the class? how about changing the form action url?*
Don't worry, we got your back. This package is very flexible and customizable.
Edit the config file
Let's first start by editing the config file. Let's say we want to add a new form that allows the user to add their personal information to their profile.
-
Go to the config file, and add another nested array under the forms array with the form name and the fields
- Go to your view where you want to place the form and call
You can add more fields or remove some from the existing forms in the config file to suit your needs.
The inputTypes array in the config file show some common input field names linked to their html 5 types, that way if you don't want to specify the type of an input manually, this array will set the correct input types to the name.
For example, the email input name will have a type of email
automatically instead of the default text
You can add more names to the array, however keep in mind that the type of the name needs to be compatible with laravel Form facade.
In addition, we can also override the type of any field. check the Inline Customization
section below for more information
The rest of the config file are just bootstrap classes and div wrapper. You can change those if you are not using bootstrap.
Inline Customization
The create method for the lightning form accepts 4 arguments Lightning::create(1,[2],[3],[4])
-
First argument is a string. It is the name of the form we want to create. ex: login, register, contact...
-
This argument uses the laravel form open argument. we can pass url, route, action, method...etc ex:
-
Here we can add or edit fields to the form and their attributes. make sure to separate the attribute name and value with a colon
:
and a comma,
between the attributes. ex: - Last argument is an array for the submit button. ex:
Take a look at this example. We are going to customize the registration form
The code above will create a registration form with the default fields in the config file in addition to two new fields (age, mobile). if you want to override an existing field attributes, simply pass the name of the field and the attributes you want to add or override.