TALL-forms
  • TALL-forms
  • Installation
    • Quickstart: Artisan cmd
    • Manual installation
      • Package
      • Translations
      • Css & Theme
      • Javascript
      • Tailwind
      • Laravel Mix
      • Wrapper view
      • Laravel Jetstream/Breeze
  • Upgrade v7 to v8
    • Configuration changes
    • Component & Field changes
    • Blade view changes
    • Notification changes
    • Styling changes
  • Concept
    • Configuration
    • Validation
    • Styling
    • Icons
    • Javascript
    • Layout vs Wrapper
    • Model binding
    • Manually saving data
    • Extend Blade Components
  • Create Forms
    • Form Data
    • Form Types
      • Standard form
      • As modal
      • Without buttons
      • Fields only
      • Headless
    • Form attributes
    • Form buttons
    • Form slots
    • Form methods
    • Lifecycle hooks
    • Render a form
    • Mass generate
  • Fields
    • Declaration
    • Labels
    • Field Slots
    • Field methods
    • Custom field attributes
    • Conditional field
    • Custom view
    • Custom field
    • Custom Livewire component
    • Relations
    • Fields
      • Checkbox
      • Checkboxes
      • FileUpload
      • Honeypot
      • ImageCropper
      • Input
      • Password
      • InputArray
      • KeyVal (array)
      • Radio
      • Range
      • Repeater (array)
      • Search
      • Select & Multiselect
      • Tags
      • TagsSearch
      • Textarea
      • Trix
      • SpatieTags
    • Sponsor Fields
      • More Inputs
      • CKEditor
      • DatePicker
      • Heading
      • Markdown
      • Panels
      • SearchList
      • SelectOptGroup
      • Tabs
      • Trix, file-uploads
  • Blade components
    • Notifications
    • Label wrapper
    • Button
    • Modal blade component
    • Modal form blade component
  • Examples
    • Input examples
    • Array fields example
Powered by GitBook
On this page
  • DEPRECATED!
  • Use Tags or TagSearch instead.

Was this helpful?

  1. Fields
  2. Fields

SpatieTags

Nested Livewire Component

PreviousTrixNextSponsor Fields

Last updated 3 years ago

Was this helpful?

DEPRECATED!

If you decide to use this field anyway, know that you'll get an error in console: Livewire: Multiple root elements detected. This is not supported.

Livewire doesn't regenerate the child components wire:end attribute.

It's only a warning but it may break other js. See:

Use or instead.

The component still exists in the codebase but it won't be maintained. If you continue to use it, you have to add the listener to your components.

protected $listeners = ['tallFillField'];

public function tallFillField($array)
{
    $this->tags = $array['value'];
}

Important. If you have any issues in your form. Try to put this field last. Livewire/Alpine can get messy when there are nested components.

If your Eloquent model exists the Spatie Tags Livewire component syncs the tags with the model. No handler or listener required.

If your Eloquent model doesn't exist you must sync the tags, after creating the model. You also have to add a handler and listener, see below.

Livewire component with User

public $tags;
public ?User $user;

//Add a listener/handler if "User" doesn't exist
//This is normally handled by the TallForms trait,
//but if the field is headless, you must add it manually.

//The SpatieTags component only emits an event if !$model->exists.
protected $listeners = ['tallFillField'];

public function tallFillField($array)
{
    $this->tags = $array['value'];
}


public function submit()
{
    if(!$user->exists) {
        //create the User
        //sync the tags, see TallForms\Traits\Helpers syncTags()
    }
}

Blade

<livewire:tall-spatie-tags
    :model="$user"
    :field="SpatieTags::blade('tags')->fieldToArray()"
    :tags="$tags"
/>

https://github.com/livewire/livewire/discussions/3887
Tags
TagSearch