FilamentF
Filament10mo ago
wheels

Livewire Entangle Error on RichText for a dynamic JSON field

I have a Tabs component, and within that I have an "Images" Tab.
Within the images Tab, I am looping through several sections to set up images with alts and abstracts.

Section::make($this->getName())
    ->statePath($this->getId())
    ->schema([
      TextInput::make('alt'),
      RichEditor::make('abstract'),
      $imageField,
]);

This will be stored within a JSON field, on "data.images.icon1.abstract" where icon1 changes.
These fields are only loaded into the page after a select input is updated:
Select::make('section_type')
  ->options(self::getSectionTypes())
  ->live()
  ->afterStateUpdated(function (Select $component) {
    $component
      ->getContainer()
      ->getComponent('dynamicFields')
      ->fill();
  }),

However, when creating a record the abstract data is not saved. When updating an existing record, it is saved with no issues.
If I change the abstract to a TextInput rather than a RichEditor, it saves successfully on creation.
If I dump out the $data in mutateFormDataBeforeCreate I can see that abstract is null, even if I have entered text into the rich text field.

Any ideas please? Let me know if my explanation does not make sense and I will try and be clearer.
Was this page helpful?