The data entry form accommodates a diverse array of input fields. It constitutes a distinct component within the delegate class \App\Admin\Delegates\Form
. Moreover, the delegate offers supplementary aids such as tabGeneral
to facilitate the construction of pre-configured tables.
use App\Admin\Delegates\Card;
use App\Admin\Delegates\Form;
use App\Admin\Delegates\Tab;
use Admin\Page;
public function matrix(Page $page, Card $card, Form $form, Tab $tab)
{
return $page->card(
$card->form(
$form->ifEdit()->info_id(),
...
$form->ifEdit()->info_updated_at(),
$form->ifEdit()->info_created_at(),
),
$card->footer_form(),
);
//OR
return $page->card(
$card->form(
$form->tabGeneral(
$tab->input_name,
...
)
),
$card->footer_form(),
);
}
When a property or method begins with [input method]_*
, an option emerges to designate a name within the model or property name, such as input_name
. In case of a method, the initial parameter pertains to the label configuration, set as ->input_name('Name of row')
.
Inputs can be embedded not only in the form, so you can create new tabs inside the form or combine them with other components.
The following enumerates all available input options that can be integrated. The form facilitates mass methods, which are individually accessible for all inputs as well.
This setting adjusts the layout of the group title to be displayed vertically instead of horizontally.
$form->vertical()
This setting adjusts the layout of the group title to be displayed horizontally instead of vertically.
$form->horizontal()
This setting flips the orientation of the group title.
$form->reversed()
This setting determines the number of columns in the header when the group is displayed horizontally.
$form->label_width(int $width)
This abstraction class is the main class from which all inputs are inherited. All methods that this abstract class supports are the same for all other inputs.
This setting specifies that the group with the title should be displayed vertically.
$form->input(...)->vertical()
This setting specifies that the group with the title should be displayed horizontally.
$form->input(...)->horizontal()
This setting allows you to specify the number of header columns to display in horizontal mode.
$form->input(...)->label_width(int $width)
This feature enables you to retrieve the value of an input from the Request
parameters using the input name.
$form->input(...)->queryable()
This functionality permits you to set a predetermined value for the input field.
$form->input(...)->value($value)
This feature enables you to establish a default value for the input field.
$form->input(...)->default($value)
This functionality allows you to set a default value for an input field from an existing model, even if the name of the model differs from the input name.
$form->input(...)->defaultFromModel(string $path)
This functionality encrypts the value of a field before storing it, providing an additional layer of security for sensitive data.
$form->input(...)->crypt()
This feature allows adding additional information to the input field, providing users with guidance or context about the expected input.
$form->input(...)->info(string $info)
This feature enables processing the value of an input field with a custom function after it has been generated or retrieved. It allows for further customization or manipulation of the input value before it is displayed or used.
$form->input(...)->value_to(callable $call)
This functionality makes the fields optional for input, meaning they are not required to be filled out. Additionally, it adds the corresponding rule to the validation, ensuring that if the field is left blank, it will pass validation without an error.
$form->input(...)->nullable()
This feature disables the input, preventing users from entering or modifying its value. It renders the input non-editable, essentially locking its current value.
$form->input(...)->disabled()
This functionality applies a mask to the input, enforcing a specific format for user input. Masks are patterns that define how data should be formatted as it is entered into an input field. They can be used, for example, to enforce consistent formatting for phone numbers, dates, or credit card numbers.
$form->input(...)->mask(string $mask)
https://github.com/RobinHerbots/Inputmask
This function constantly copies its value as a slug into the input whose ID was specified. It is designed to automatically generate a slug based on the input value and its unique identifier.
$form->input(...)->duplication_how_slug('#input_slug')
This function continually duplicates its value into the input field with the specified ID. It's useful for automatically populating one input field with the value of another input field identified by its ID.
$form->input(...)->duplication('#input_slug')
This function converts the input string into a slug format. A slug is a URL-friendly version of a string, typically used in URLs to represent the title of a resource. It removes special characters, replaces spaces with hyphens, and converts all characters to lowercase.
$form->input(...)->slugable()
Supports all Laravel
validation methods. The available list of validation methods can be seen in file at link.
This input field provides a simple and straightforward way for users to enter textual information. It is commonly used for entering short text such as names, descriptions, or comments.
$form->input('login', 'Login')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This input field is specifically designed for entering numerical values with decimal points, such as prices, quantities, or measurements. It allows users to input floating-point numbers accurately and efficiently.
$form->amount('price', 'Product price')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This input field provides a sophisticated data entry experience with auto-completion functionality. As users input data, the field dynamically loads additional relevant information to facilitate quick and accurate completion of the entry. This feature enhances user productivity by reducing the need for manual input and streamlining the data entry process.
$form->autocomplete('tags[]', 'Post tags')->options(PostTag::pluck('id', 'name'))
// OR
$form->autocomplete('tags[]', 'Post tags')->load(PostTag::class)
The loading rules for this field function in the same way as the rules for a basic selector. This means that they follow similar principles and behaviors, ensuring consistency and familiarity for users.
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature provides a straightforward group of checkboxes intended to activate or deactivate certain elements within an array property of the model.
$form->checks('roles[]', 'User roles')->options(Roles::pluck('id', 'name'))
This functionality offers a sophisticated editor equipped with text formatting capabilities and the option to insert images.
$form->ckeditor('description', 'Post description')
This feature provides a sophisticated editor tailored for "code" text, complete with syntax highlighting.
$form->codemirror('template', 'Mail template')
This feature offers a complex input option featuring a dropdown color palette for selection.
$form->color('color', 'Tag color')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature provides a sophisticated input option with a dropdown calendar, enabling users to select a date easily.
$form->date('birthday', 'User birthday')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature offers a sophisticated input option with dropdown calendars, allowing users to select a date range conveniently.
$form->date_range('subscribed_range', 'User subscribed')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This functionality provides a sophisticated input feature with a dropdown calendar for selecting both date and time.
$form->date_time('verify_at', 'User verify at')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature offers a sophisticated input with dropdown calendars for selecting both a start and end date and time, defining an interval.
$form->date_time_range('subscribed_range', 'User subscribed')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This functionality provides a sophisticated double list for selecting multiple items.
$form->dual_select('categories[]', 'Prodict categories')->options(Category::pluck('id', 'name'))
This feature offers a basic input field with data validation specifically for email input.
$form->email('email', 'User email')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature provides a sophisticated input method for selecting an image from the local file system.
$form->file('download_file', 'Download file')
This feature offers a straightforward hidden data field.
$form->hidden('user_id')->value(admin()->user_id)
This feature provides a sophisticated input field with a dropdown list of icons available in the FontAwesome library.
$form->icon('icon', 'Menu icon')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature offers a complex input field for selecting a image from the local system.
$form->image('avatar', 'User avatar')
This feature provides a simple input field in the form of an input where information is displayed.
$form->info('id', 'ID')
// OR
$form->info('created_at', 'Created at')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature provides a sophisticated MarkDown text editor for inputting and formatting text content.
$form->mdeditor('body', 'Post body')
This feature offers a complex multi-select data field represented by a drop-down list, allowing users to select multiple items from the list.
$form->multi_select('roles[]', 'User roles')->options(Roles::pluck('id', 'name'))
// OR
$form->multi_select('roles[]', 'User roles')->load(Roles::class)
The loading rules for this field function in the same way as the rules for a basic selector. This means that they follow similar principles and behaviors, ensuring consistency and familiarity for users.
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
This feature provides a complex field for entering integers, ensuring users can input whole numbers accurately.
$form->number('days', 'Trial days')
This functionality offers a straightforward field for users to input prime and non-prime numbers, facilitating the entry of both types of numeric values.
$form->numeric('percent', 'Percent of discount')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
A simple password input field provides a secure way for users to input sensitive information. This input type typically masks characters to prevent others from viewing the entered text. It's essential for protecting user accounts and ensuring data security.
$form->password('password', 'User password')
If you require an additional confirmation field, you can utilize the helper function to add an extra layer of security. This is commonly used in scenarios where sensitive actions are involved, such as changing passwords or deleting accounts. Adding a confirmation field ensures that users perform the action intentionally, reducing the risk of accidental changes.
$form->password('password', 'User password')->confirm()
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
A simple field for selecting one value from a list of checkboxes provides users with the option to choose a single item from a predefined set of choices. This input method is useful when you want users to select one option from multiple available options. It ensures that only one selection is allowed, providing clarity and simplicity in user interactions.
$form->radios('roles', 'User roles')->options(Roles::pluck('id', 'name'))
A complex input in the form of rating stars allows users to rate an item by selecting a specific number of stars. This input method typically displays a set of stars, and users can click on a star to indicate their rating. It's commonly used for rating products, services, or other items where a qualitative assessment is required. The number of stars selected represents the user's rating, with more stars indicating a higher rating.
$form->rating('stars', 'Commentary stars')
A complex drop-down list with sorting functionality provides users with a list of options to choose from, with the added feature of sorting the options. This type of input field typically displays a list of items in a dropdown menu, allowing users to select one option. However, it also includes the ability to sort the items within the dropdown menu, making it easier for users to find and select the desired option. Sorting functionality can be based on various criteria such as alphabetical order, numerical order, or custom sorting rules. This enhances the usability of the dropdown list, especially when dealing with a large number of options.
$form->select('city_id', 'User city')->options(City::pluck('id', 'name'))
// OR
$form->select('city_id', 'User city')->load(City::class)
It is also possible to link downloads to each other if you have multiple selectors that can depend on each other. For example, selecting a city based on the selected country:
$form->select('country_id', 'User country')->load(Country::class)
$form->select('city_id', 'User city')->load(City::class, '{id}) {name}', function ($builder, array $form) {
return $builder->where('country_id', $form['country_id'] ?? 0);
})
// OR
$form->select('city_id', 'User city')->load(
City::class,
'{id}) {name}',
fn ($q, array $form) => $q->where('country_id', $form['country_id'] ?? 0)
)
Option format seated like variables. Format {id}) {name}
show some sing like that 5) test name
. Where id
and name
is fields of model. You can set also first level of relations like this {id}) {name} {relationName.relationField}
.
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
A complex input for entering an unlimited number of sequential data allows users to input multiple data entries in a structured and sequential manner.
$form->select_tags('tags', 'Post tags')
// OR
$form->select_tags('tags', 'Post tags')->options(MyTags::pluck('name', 'id'))
// OR
$form->select_tags('tags', 'Post tags')->load(MyTags::class)
The loading rules for this field function in the same way as the rules for a basic selector. This means that they follow similar principles and behaviors, ensuring consistency and familiarity for users.
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
A complex switch between 1 and 0 provides users with a versatile input mechanism to toggle between two states, typically represented by the values 1 and 0. This type of switch may offer additional features and functionality compared to a standard binary switch.
$form->switcher('active', 'Post active')
A simple field for entering multi-line data provides users with a straightforward and intuitive interface for inputting text or data that spans multiple lines.
$form->textarea('about', 'User about')
A complex field with a drop-down interface for selecting the time provides users with a user-friendly and intuitive way to input time values.
$form->time('run_every', 'User schedule')
Supports the icon methods of the FontAwesome
library. Available list of links to icons can be seen in file at link.
A slider component is a user interface element that allows users to select a value from a range by moving a draggable handle along a track.
$form->slider('complete', 'Complete proccess')->min(1)->max(100)->step(1)
A special field for grouping model link inputs is designed to handle situations where the main model in your application has a one-to-many relationship with other models, typically represented by a hasMany
relationship. This field is particularly useful for managing related records and selecting multiple linked records within a single form.
$form->model_relation('basket')->template(
...
)
A component designed to clone Simple input elements with the addition of a prefix to the input
name can be a powerful tool for managing multilingual content within your application.
$form->lang()->input('name', 'Label');
This is equivalent to the following construction:
// Since the default setting is 3 languages "en", "uk", "ru"
$content->input('name[en]', 'Label EN');
$content->input('name[uk]', 'Label UK');
$content->input('name[ru]', 'Label RU');
I recommend using the spatie/laravel-translatable package as this is the one I have used and only tested with. Using other packages does not guarantee the absence of bugs.