Download the PHP package toriomlab/eloquent-form-elements without Composer

On this page you can find all versions of the php package toriomlab/eloquent-form-elements. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eloquent-form-elements

Eloquent-Fields Generator Package For Laravel

This package actually contains a helper function and a trait. Its basic target is to reduce time that developers spend writing Creation & Update forms markup for Eloquent Models.

It's basic idea is to use the FormGenerator trait in your model and write a tiny array with your fields' preferences. Then you can use the helper function to generate a creation or update form.

Installing.

Via composer

Then in your model use the trait toriomlab\EloquentFormElements\Traits\FormGenerator like the following:

How to use it?

By defining a static array in your model called $fields and its structure should be as following example.

This will generate a bootstrap form-group div contains this field. Then you can generate a creation form fields in your view files like the following example:

And you can create an update form fields by passing a second parameter contains the object id.

So this actually will generate an update form fields for the row which its id is 1.

Full Guide

$fields array writing rules.
  1. Must provide label.
  2. Must provide input which can be input, select or textarea.

If the input index is input you must provide a type index to provide the input type like text or number or date etc.

If the input type is select you can provide an options index which will contain an array for the select dropdown options. Or you can provide a relation index which will get options from a relation in the eloquent model.

Relation array

There's three types of Eloquent Relatioships supported till now in the package. You have to provide a type index in the relation array to specify the relation type based on the following:

  1. belongsTo its type will be one because we will only select one option in this case.
  2. hasMany Or belongsToMany: their type will be many because we will select multiple values.

If the type index in the relation array is one you will need to provide

If the type index in the relation array is many you will need to provide

You will also need to provide a selectFrom and valueFrom as well.

If the input is a select you can provide a valueFallback which will be a static method returns all the options in the dropdown and then you need to provide a valueCallback which will return the selected options collection.

Additional Preferences

There are multiple additional things that can be very usefull in all your fields specifications.

  1. label_classes which is the label class attribute value. You can override the default classes which are control-label col-md-4.
  2. input_div_classes which is the class attribute of the div that contains the input code. By default it's col-md-6.
  3. input_classes:which is the class attribute of the input itself. By default it's form-control.
  4. input_id which is the id attribute of the input itself. By default it's the field name.
  5. inject_attributes which allows you to add additional attributes to the input. It just takes the string and put it in the input tag.

Examples.

Generate normal text field:

Generate number field:

Generate HTML Image:

Generate HTML Line:

If the model belongs to a role and we wanna make a select field for the roles.

What if the model belongs to many roles?

A full example how should be the $fields array of a user model.

Example for valueCallbacks and valueFallbacks.

Example for manual belongsTo relation with createValueCallbacks and updateValueFallbacks.

Then you can just call generate_fields('App\User') to generate a creation form fields or generate_fields('App\User', 1) to generate an update form fields for User whose id is 1.

Notice that you can pass a third parameter to generate_fields parameter to except one or many fields from being generated in the form.

So if we called generate_fields('App\User', null, 'age') a creation form will be created without age field. You can also pass an array so generate_fields('App\User', null, ['age', 'roles']) will create a creation form without roles and age fields.

Don't hesitate to make a pull request or post an issue if found.
This package is cloned from lilessam/eloquent-fields

All versions of eloquent-form-elements with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.0
illuminate/support Version ~5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package toriomlab/eloquent-form-elements contains the following files

Loading the files please wait ....