Skip to content

Livewire child component

tanthammar edited this page Sep 25, 2020 · 2 revisions

livewireComponent($component, $params = [])

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.

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