Download the PHP package sujan/laraform without Composer
On this page you can find all versions of the php package sujan/laraform. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sujan/laraform
More information about sujan/laraform
Files in sujan/laraform
Package laraform
Short Description HTML and Form Builders for the Laravel Framework from YAML and JSON
License MIT
Informations about the package laraform
YAML, JSON to html form with validation for laravel
Developing rapid forms from YAML and JSON, when large number of input fields will be required as well as frequent addition and deduction of form fields.
Installation
As sujan/laraform
package is based on laravelcollective/html
you have to add your new
provider to the providers array of config/app.php:
Finally, add two class aliases to the aliases array of config/app.php:
Then run the command
It will give you a laraform.css
file in /css/laraform.css
Then add laraform.css
to your master template like
Usage
This package has multi purpose usage. You will get all the facilities of Laravel Collective
as well as facilities of sujan/laraform
package. We developed this package based on real life scenario.
Scenario 1
Say you have to develop a key value store where all of your application settings will reside. The kick here is to add more and more new keys when needed but no code modification will be needed. Then this is the right package for you. All you have to do is to write a YAML or JSON file for your form.
Scenario 2
Let's assume the values of your settings will come as a nested object and you have to make a form for the object then this package is a good choice. It will build the form for you within a few minutes all you have to do is write the JSON or YAML file based on the JSON object.
How to Use
Use it inside form tag in your form like
Laraform support input types text
, email
, password
, number
, hidden
, date
, file
, textarea
, checkbox
, select
,
radio
, checkboxlist
, section
;
Example 1
Let's say you have a users
table and a usersmeta
table.
In users
table you will save name
,email
, password
and in usersmeta
table you want to save
date_of_birth
, color
, gender
, address
, favourites
, profile_pic
.
Your yaml
and json
file will be like below. Where usermeta
is relation name.
Our package will parse the form for you.
Sample YAML for Example 1
Sample JSON for Example 1
Here span
left, right is used to push the input fields to left and right.
If you don’t specify span then the span will be full by default.
Sample create form
Html form of sample YAML and JSON.
Form validation rule:
Html form of sample YAML and JSON with validation message.
The YAML and JSON files work for both create and edit page, all you have to do is to pass the model instance or JSON object.
Sample edit form for the above example.
Here variable $model
is model instance or JSON object like below.
Sample JSON object
Sample edit form of the above JSON object
Sample edit form with validation message
The yaml
and json
file for the above object will be #Sample 1
's two files.
Form validation
You have to use laravel's form validation methodology. The error message handling is included in the package. So you don't have to write code for showing error messages. The message will be shown below the input field marked red.