Download the PHP package coyote6/laravel-forms without Composer
On this page you can find all versions of the php package coyote6/laravel-forms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coyote6/laravel-forms
More information about coyote6/laravel-forms
Files in coyote6/laravel-forms
Package laravel-forms
Short Description Simple class used to generate the html for forms and assist with the validation process in Laravel with optional Livewire and Tailwind integration.
License MIT
Homepage https://coyote6.com
Informations about the package laravel-forms
Laravel Forms
About The Project
Laravel Forms is class based form package used to generate the html for the forms and assist with simple validation process in Laravel. This project is still in development, so documentation will be slow going.
Prerequisites
- PHP 8.0 or Higher
- Laravel 8+ Install
Getting Started
Install via composer:
Optional - Copy the config file to your config folder.
To Use
Basic Example
In the controller file
In Blade Template
Best Practice
For best use it is recommended to set up the form in the controller under its own private/protected method, so that it may be reused for validation.
In the controller file
Validation
Use with Livewire
In the your base app blade template, below where you call @livewireScripts, add a stack('scripts') call if you haven't already done so.
In the component (Basic Method)
In the component (Using Coyote6\LaravelForms\Livewire\Component)
In the Livewire Blade Template
In the Web Routes File -- Optional
Use with Tailwind CSS
Tailwind is now the default theming for the forms. You must already have tailwind purchased, installed, and configured.
Some non-tailwind classes are added to items automatically. These are generic class names such as .form-item, .label, .field, etc. You can shut them off in the .env file using:
Or if you published the config file, you can set default-classes
to false.
If you wish to change the default tailwind classes, they are stored in the classes section of the config file. Additional styling options are set in there as well.
Theming
You can theme the forms in a couple ways.
The first which is mentioned above is to edit the config file and overriding the classes.
The other is to copy the files from the -/src/Resources/views/- directory (sorry haven't wrote the publish command yet, but will.) and move any of these files into -resources/views/- directory in your app. The package will check your directory for files and use it over the default files. Be sure to set caching to false on either your individual form/field or set the master caching to false in the config. The template naming conventions are as follows:
-resources/views/forms/{$template}--{$element_id}.blade.php- -resources/views/forms/{$template}--{$element_name}.blade.php- -resources/views/forms/{$theme}/{$template}.blade.php- -resources/views/forms/{$template}--{$theme}.blade.php- -vendor/coyote6/laravel-forms/src/resources/views/forms/{$theme}/{$template}.blade.php- -vendor/coyote6/laravel-forms/src/resources/views/forms/{$template}--{$theme}.blade.php- -resources/views/forms/{$template}.blade.php- -vendor/coyote6/laravel-forms/src/resources/views/forms/{$template}.blade.php-
You can merge your custom classes to any of the attribute variables in the templates:
To utilize a theme on certain forms, and set classes from the config method, set the theme when constructing the form.
If you just with to override the templates without setting classes from the config file, then you can call it anytime before rendering or validating.
Fields will inherit their parent's theme if it is set during the construction, or before fields are added.
Available Fields (More to come)
Button - <button>
Checkbox - <input type="checkbox">
Email - <input type="email">
Simple Email
Email w/ Confirmation
Field Group - <div>
This just wraps a group of fields. It can have a label, if desired.
File - <input type="file">
Setting Default Value, Removing Images, & Retrieving Image w/o Livewire
Single File
Note: Non-Livewire documentation may be out of date as I have not had time to test.
Multi File
Setting Default Value, Removing Images, & Retrieving Image w/ Livewire
The field will add 4 additional properties to the Livewire component. These are properties for previously uploaded files, previously uploaded files that are removed, and all files that up-to-date, and temporary access times for image previews. These properties can be accessed by adding 'PreviousUploads', 'Removed', 'All', 'TempAccessTimes' to the Livewire property. For example, if the property is set to $this->file then the values can be accessed via $this->filePreviousUploads, $this->fileRemoved, $this->fileAll, $this->fileTempAccessTimes respectively.
Note: $this->imageAll may not be updated until after the form is generated or validated.
Single File
Multi File
Hidden - <input type="hidden">
Html - <div>
Image - <input type="file">
This is the same as a file field, but is restricted to image files.
Number - <input type="number">
Password - <input type="password">
Simple Password
Password w/ Confirm
Radio Buttons - <input type="radio">
Simple Radio Button
Radio Buttons with HTML
Select - <select>
Submit Button - <button> or <input type="submit">
Rendered as a Primary/Submit <button>
Rendered as Secondary <button>
Rendered as <input type="submit">
Text - <input type="text">
Textarea - <textarea>
More fields coming in the future.