Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save form with Builder + RichEditor causing Undefined array key "type" #7957

Closed
howdu opened this issue Aug 21, 2023 · 5 comments
Closed

Save form with Builder + RichEditor causing Undefined array key "type" #7957

howdu opened this issue Aug 21, 2023 · 5 comments

Comments

@howdu
Copy link
Contributor

howdu commented Aug 21, 2023

Package

filament/filament

Package Version

v3.0.28

Laravel Version

10.19.0

Livewire Version

v3.0.0-beta.10

PHP Version

8.1.14

Problem description

An issue with the Builder when it contains a RichEditor.

On first saves it works but throws an error on the third save.

Forms\Components\Repeater::make('addresses')
    ->relationship('addresses')
    ->schema([
        Forms\Components\Builder::make('blocks')
            ->minItems(1)
            ->required()
            ->blocks([
                Forms\Components\Builder\Block::make('block')
                    ->schema([
                        Forms\Components\RichEditor::make('address1')
                    ])
            ])
    ])

Checking the Livewire request it looks to be getting mixed up with two keys that refer to the same block.

{
  "_token": "123",
  "components": [
    {
      "updates": {
        "data.addresses.record-2.blocks.5a9f0253-1c13-4af3-8c9d-66bbe6694403.data.address1": "<p>Test2345</p>",
        "data.addresses.record-2.blocks.5faf51e2-d957-4b46-ac23-f313b0e3f1fe": {
          "data": {
            "address1": null
          }
        }
      },
      "calls": [
        {
          "path": "",
          "method": "save",
          "params": []
        }
      ]
    }
  ]
}

Error is thrown from Undefined array key "type" but appears to be issue from the Livewire request

public function getChildComponentContainers(bool $withHidden = false): array
    {
        return collect($this->getState())
            ->filter(fn (array $itemData): bool => $this->hasBlock($itemData['type']))
Screen.Recording.2023-08-21.at.12.59.21.mov

Expected behavior

Save to work each time.

Steps to reproduce

  • Create a 'Customer' record.
  • Edit customer.
  • Click save multiple times.

Reproduction repository

https://github.com/howdu/filament-tester

Relevant log output

No response

@howdu howdu added bug Something isn't working unconfirmed labels Aug 21, 2023
@Focusnik
Copy link

Still relevant on liveware 3.0.0-beta10

@pboivin
Copy link
Contributor

pboivin commented Aug 22, 2023

Related to #7450

@danharrin danharrin added this to the v3 milestone Aug 23, 2023
@danharrin danharrin added bug in dependency and removed bug Something isn't working labels Aug 23, 2023
@danharrin
Copy link
Member

I believe livewire/livewire#6521 is a failing test for this

@lukas-frey
Copy link
Contributor

lukas-frey commented Aug 28, 2023

Can confirm this. It happens with any kind of "repeating" component, such as Builder, Repeater, etc.

After you add an item, remove it and then repeat the same process it will throw that error.

EDIT: sorry, didn't realise that it was already fixed and waiting for release in Livewire :)

@howdu
Copy link
Contributor Author

howdu commented Sep 7, 2023

Fixed in Livewire v3.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants