Skip to content

Field Options

tanthammar edited this page Sep 25, 2020 · 2 revisions

default($default)

Sets the default value to use for the field. $default = The default value.

Field::make('City')->input()->default('Toronto'),

autocomplete($autocomplete)

Sets the autocomplete value to use for the field. $autocomplete = The autocomplete value.

Field::make('Password')->input('password')->autocomplete('new-password'),

placeholder($placeholder)

Sets the placeholder value to use for the field. $placeholder = The placeholder value.

Field::make('Country')->input()->placeholder('What country do you live in?'),

help($help)

Sets the help text to use below the field. $help = The help text.

Field::make('City')->input()->help('Please enter your current city.'),

errorMsg(string $message)

Set a custom text to be displayed instead of the default message on validation errors. $message = The custom validation message.

Field::make('City')->input()->help('Please enter your current city.'),

prefix($prefix)

Sets the prefix text displayed in front of the field, with a gray background. $prefix = The prefix text.

Field::make('Url')->input('url')->prefix('https://'),

icon($icon) see Icons page->

Sets the icon displayed in front of the field, with a gray background. $icon = The path to the svg icon. (The icon is placed before prefix if both are applied.)

Field::make('Url')->input('url')->icon('light/globe'),

step(float), min(float), max(float)

Available for inputs of type number, range, date, datetime-local, month, time, week See the documentation for Range slider

view($view)

Sets a custom view to use for the field. Useful for more complex field elements not included in the package. $view = The custom view.

Example custom view file:

{{-- fields/custom-field.blade.php --}}
<div class="form-group row">
    <label for="{{ $field->name }}" class="col-md-2 col-form-label text-md-right">
        {{ $field->label }}
    </label>

    <div class="col-md">
        <input
            id="{{ $field->name }}"
            type="text"
            class="custom-field-class form-control @error($field->key) is-invalid @enderror"
            wire:model.lazy="{{ $field->key }}">

        @include('tall-forms::fields.error-help')
    </div>
</div>

Custom views are passed $field, $form_data, and $model variables, as well as any other public component properties.

Example custom view field declaration:

Field::make('Custom Field')->view('fields.custom-field');

Clone this wiki locally