Download the PHP package webfactor/laravel-backpack-instant-fields without Composer

On this page you can find all versions of the php package webfactor/laravel-backpack-instant-fields. 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 laravel-backpack-instant-fields

laravel-backpack-instant-fields

Latest Version on Packagist StyleCI Build Status Coverage Status Quality Score Total Downloads

This is a package for Laravel Backpack and provides CRUD field types which allow to create/edit/delete a related CRUD entity on-the-fly while adding/editing another.

Screenshot

Screenshot

Install

Via Composer

Usage

EntityCrudController

For simplicity add the InstantFields trait from this package to all EntityCrudControllers which are supposed to provide "instant fields" or are triggered by "instant fields".

This trait provides all needed route entry points methods and ajax response methods.

Routes

in your routes file you have to add one additional route in your CRUD::resource for each Entity that uses the packages trait. For clarity we recommend to use the with() helper:

The trait/route will handle the following requests for you:

Available Fields

There are two field types available in this package which allow you an instant creation of related models (1-n and n-m). They are modified versions of the equivalent field types that already exist in Laravel Backpack:

Attention:

Edit and delete buttons are only available for select2_from_ajax
Please consider your database constraints when using the delete button!

Field Definition

Please set the $ajaxEntity property by using the setter in the setup()-method of the (foreign) EntityCrudController that is triggered by an "instant field":

In the field definition of the EntityCrudController where your instant field is setup you will have to set the above name in the on_the_fly-Array.

Note: If you use Laravel Backpack Crud >=3.4.11 you don't have to publish the provided fields, you can use them directly from the package by using the view_namespace key.

Example:

Instant Fields will try to auto-fill the select2 input after creating a new entry. It will assume that an input field exists with the name name and will use its value for the triggered ajax search. If you want to use another field for this, just add attribute to the on_the_fly-array containing the field name you want to use.

Sometimes you may need a simple Button/Link to the "real" foreign entity without a modal: Just add 'crud' => true in that case

List view

With this package your are also able to add a create button for the foreign CRUD entity in your list view of Backpack! Just add the following line in your EntityCrudController:

Customization

Modal view

By route

By default the modals are loaded automatically by using entity in on_the_fly of the field definition, e.g. resulting in backpack_url($field['on_the_fly']['entity']).'/ajax/create' for the create modal.

You can overwrite this behavior for all modals by setting an attribute:

Please be aware that by using this attributes you will be completely responsible for the content of the modal! The defined request has to provide valid HTML which is then filled in <div class="modal-content"></div>

By view

Instead of defining a route you can also use a custom view by:

Search logic

The "instant field" triggers the ajaxIndex() of the EntityCrudController where the field is defined and uses the fields model and attribute parameters to perform the search on the foreign model.

By adding search_logic to the field defintion you can implement your own searching behavior:

Collecion $form is an optional parameter and provides all current values of your CRUD form. You can use it to manipulate your search depending on actual inputs and in combination with dependencies (see Backpack Documentation)

Furthermore you can then use attibute to display enriched values in the dropdown by using an accessor on the model.

Search data source

If needed you are free to use the data_source and method attributes from the original field blades which come with Laravel Backpack. This is the URL that is triggered by the select2 field for searching.

Request validation

You can also use Request Validation! Just set the $ajaxStoreRequest and/or $ajaxUpdateRequest property by using the provided setter method:

Auto-fill after store/update

Instant Fields will try to auto-fill the select2 input after creating a new entry. It will assume that an input field exists with the name name and will use its value for the triggered ajax search.

You can add an autofill_attributes array, if you want to define one or multiple auto-fill columns:

Please note that this only works with columns (or appended accessors).

In order for this to work properly on multiple columns, you should implement a custom search logic for the field.

Search logic example:

Passing current field values to foreign EntityCrudController

Sometimes you will need current values to be used for the creation of an foreign entity. You may define serialize with the IDs of the fields you need in the store request:

So the current values of type_id and name will be available in the $request of the ajaxStore method of your foreign EntityCrudController (you will have to overwrite it).

Fields

Publish the fields in your project and modify functionality

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-backpack-instant-fields with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0
illuminate/database Version ~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0
php Version ~7.1
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 webfactor/laravel-backpack-instant-fields contains the following files

Loading the files please wait ....