Skip to content

BaseField Slots

tanthammar edited this page Nov 18, 2020 · 3 revisions

Display text

BaseField slots Example

Input::make('Label')
    ->before('Before')
    ->after('After')
    ->above('Above')
    ->below('Below')
    ->help('Some help text')
    ->icon('file-user'), //requires blade ui kit icons

->before(string $text)

->after(string $text)

->above(string $text)

->below(string $text)

->help(string $help)

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

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

Replace field slots with custom views

->view(string $your_on_your_own_blade_view)

  • Display a custom view instead of the default field view
  • The view will have access to $field, $form_data, and $model variables, as well as any other public component properties.
  • @param string $blade_view_to_include
Input::make('Custom Field')->view('fields.custom-field');

->beforeView(string $blade_view_to_include)

->afterView(string $blade_view_to_include)

->afterLabelView(string $blade_view_to_include)


Label related

BaseField label

->hideLabel()

->labelWidth(string $class)

  • Used only in inline form
  • Default sm:w-1/3

->labelAlign(string $class)

->afterLabel(string $text)

->labelSuffix(string $string)

  • useful if you want to append (*) to the label on required fields
Input::make('Label')
    ->afterLabel('After label')
    ->labelSuffix('suffix')
    ->rules('required|string'),

Custom Livewire Component

Please read the Custom Field page. It is recommended that you create a Custom Field instead of using this method.

->livewireComponent(string $component, array $params = [])

  • Replace this field with your own livewire component.
  • You can use a Livewire component as custom view for a field.
  • $component = String, the path and name (as path.name) to a livewire component
  • $params = Optional array with parameters to pass to the child component.

custom() or emitUp()

In this example we are using the custom() method to tell the component that we want to handle this field manually. (see docs for custom field). Another option could be to do emitUp() (see Livewire docs) in the child component to populate the field in the main form component.

Example

The example is for a fictive Livewire/App/Tags component with three properties.

Input::make('Tags')
    ->custom()
    ->livewireComponent("app.tags",
        [
            'model' => $this->model,
            'tagType' => "event",
            'setLocale' => "sv"
        ]),
Clone this wiki locally