Declaration

::make vs ::blade

In a Standard form, Modal or Without button forms, you use the make() method

FooField::make(string $label, null|string $key = null)

In Headless or Fields only forms you use the blade() method

FooField::blade(
    string $label, 
    null|string $key = null, 
    string $wireId = '', 
    string $name = '', 
    string $id = ''
)

Both ::make and ::blade params

$label

Required The label to use for the form field, e.g. First Name.

$key (wire:model)

Optional. The key to use for the form field. If null, it will use a snake cased $label. This parameter corresponds to the $model attribute and sets the wire:model attribute on the field.

Basic input example:

 Input::make('First Name')->rules('required|min:2'),

Select field example

$brand_options = Brand::orderBy('name')->pluck('id', 'name');

Select::make('Brand', 'brand_id')
    ->options($brand_options)
    ->rules(['required', Rule::exists('brands', 'id')])

::blade only params

$id

Optional. The $id property overrides $wireId. For Headless or Fields only forms. Set the input html id attribute else, it will be auto-generated from the field $key.

Input::blade(
    label: 'My input', 
    id: 'my-input-id'
)

$wireId

Optional. The $id property overrides $wireId. For Headless or Fields only forms. Pass the Livewire $_instance->id to get a component unique input html id else, it will be auto-generated from the field $key.

Input::blade(
    label: 'My input', 
    wireId: $_instance->id,
)

$name

Optional. For Headless or Fields only forms. Set the input html name attribute else, it will be auto-generated from the field $label.

Input::blade(
    label: 'My input', 
    name: 'my-input-name'
)

Last updated