Download the PHP package adamthehutt/laravel-lean-forms without Composer

On this page you can find all versions of the php package adamthehutt/laravel-lean-forms. 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-lean-forms

Laravel Lean Forms

Installation

If you would like to change the default skin or customize templates:

Basic Usage

This package provides an expressive syntax for defining forms and fields, while allowing you to keep all domain logic outside of your Blade templates.

For example:

And then in your template you only need to worry about client-side or display logic:

Note: Be sure to compile your JavaScript assets!

Form generator

The package includes an artisan command for generating new form classes:

Of course, you are free to namespace and store form classes wherever you like.

Form configuration

In general, this package tries to make some reasonable guesses based on naming conventions, but you always have the option of being explicit. Some form class properties and methods you should know about:

$method property — Can be set to any of the standard REST HTTP verbs. If it's not explicitly set then the package will try to guess based on the form class name. For example, if the class name is (or ends with) "Create", then POST will be used; for "Edit", PUT; for "Destroy", DELETE.

$route property or method — Property can be set to the string name of a defined route. More complicated routes can implement the route() method and return, for example, route("animal.update", [$animal->id]). If neither the property nor the method is defined, then the package will try to guess based on the form class name and model name. For example, if the form class basename is AnimalEdit and the associated model is Animal, then it would guess route("animal.update", [$animal]).

$files property — Set the $files property to true if you need the form to accept file uploads.

Fields — Most of your form class logic will likely involve configuring fields. There are two ways you can do this.

  1. Define the $fields property with a simple mapping of field name to the desired Element class name, for example: $fields["foo" => Text::class]. This works in the most basic and routine scenarios. In the example above, it would result in a text field with the id and name "foo", with all default logic applied.
  2. Define a method for specific form field. This allows for extensive customization using a fluid interface. (Any of these can be used when referencing the field in a Blade template as well.) Some of the options available include:
    • name($value) — Set the form field's name (defaults to the snake_cased name of the defining method)
    • id($value) — Set the id attribute (defaults to the name)
    • label($value) — Set the label text (defaults to a user-friendly version of the name)
    • class($value) — To override the template default for the element
    • labelClass() — To override the template default for the label
    • options($map) — Key-value array or collection of options for select, radio, etc.
    • value($value) — Set the value of the field (override the model property)
    • default($value) — Set the default value if otherwise empty
    • data($key, $value) — Set a data-xyz property on the element
    • attr($key, $value) — Set an arbitrary HTML attribute
    • readonly(), multiple(), placeholder($value), etc. — Set the corresponding HTML attribute

Available field types

The following field types are currenly supported:

Blade templates

Generating the form HTML in a Blade template is as simple as calling the associated methods. You can also use method chaining to attach display or client-side logic e.g.:

Form skinning

The package supports "skinning" forms according to different conventions or standards. The default skin is Bootstrap 3, while Bootstrap 4 is also supported. (Pull requests for templates supporting other skins are more than welcome!) You can configure a default skin for your forms by setting the LEAN_FORMS_SKIN value in the .env file. You can also set it for an individual form by changing the $skin property.

Form field wrapping

The default skin automatically wraps each form field in a div.form-group element and generates a corresponding label element. You can turn off this behavior by calling:

For more fine-grained control, you can also call on a specific element or even specify the and/or properties on the field.

Determining field values

When a form loads, the field values are generally determined based on the following (descending) order of priority:

  1. Submitted form input, i.e.
  2. Explicitly assigned value, i.e.
  3. Model property for field name, i.e.
  4. Explicitly assigned default, i.e.

NB: There is additionally a special "__value" property that is used internally but you don't need to worry about it unless you're extending a form element class or modifying templates.

Finding Form Classes

You can always directly instantiate a form class using, e.g., .

You can also use the library's service container binding to locate a class. For example, if you have a form class called , you could create a new instance using:

This is a bit verbose, but it can be useful when combined with the ability to configure namespaces in the lean-forms.php config file. By defining an array of namespaces in the config file, you can set a prioritized list of namespaces to look for the form class. This allows package developers to include default form classes that can easily be overriden by prioritizing the App namespace.

The LeanFormsManager class is also invokable, so the above could be slightly shortened to:


All versions of laravel-lean-forms with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
illuminate/support Version ^5.8 | ^6.0 | ^7.0 | ^8.0
illuminate/database Version ^5.8 | ^6.0 | ^7.0 | ^8.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 adamthehutt/laravel-lean-forms contains the following files

Loading the files please wait ....