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

Repeater Field does not store values using wire:model.defer #57

Closed
viezel opened this issue Jan 11, 2021 · 3 comments
Closed

Repeater Field does not store values using wire:model.defer #57

viezel opened this issue Jan 11, 2021 · 3 comments
Labels
no-bug This doesn't seem like a bug

Comments

@viezel
Copy link

viezel commented Jan 11, 2021

Describe the bug
When using Repeater Form Field combined with wire:model.defer only the very last field in the repeater is stored. Please have a look at the screenshots attached.
I need to use "defer" due to a very large form.

Environment:

  • Tall-forms version: 7.8.0
  • Livewire version: latest
  • Laravel version: latesst
  • AlpineJS version (only needed if problem is Alpine related):
  • $wrapWithLayout true/false: false
  • Optional model binding?
  • Have you published the view files?: no
  • Have you published, and edited the config file?: no
  • Is it a Create or Update form?: both

Fields Definition

Input::make('Name')
    ->rules('required')
    ->wire('wire:model.defer'),
          
Repeater::make('Ingredients *', 'ingredients')
    ->fields([
        Input::make('Quantity')->type('number')->rules('required')->colspan(3)->wire('wire:model.defer'),
        Select::make('Unit')->options($unitList)->rules('required|integer')->colspan(3)->wire('wire:model.defer'),
        Select::make('Ingredient')->options($ingredientList)->rules('required|integer')->colspan(6)->wire('wire:model.defer'),
    ])
    ->sortable()
    ->wire('wire:model.defer')
    ->help('Click to add an Ingredient'),

Input::make('Servings')
    ->type('number')
    ->rules('required|integer')
    ->wire('wire:model.defer'),

Screenshots

If I fill out all fields and hit "save" I get:

image

The below is posted to the backend via Livewire. All the fields and input data are present.

image

If I use Selects, Input, Trix etc. outside of a Repeater - then defer works.

@tanthammar tanthammar added the no-bug This doesn't seem like a bug label Jan 12, 2021
@tanthammar
Copy link
Owner

Hi @viezel
This is something with your project. ->wire() is ignored on Repeater, KeyVal, Panel and Group fields.

I tested both updatedFoo(), saveFoo() and checked the database after normal submit.

But, I added the ->wire() methods to these field types, it's available in v7.8.1

Check that you added $cast to array on the Model for this field?
It's recommended that your field in db is a json column.

@viezel
Copy link
Author

viezel commented Jan 12, 2021

alright.. ill keep fighting. Thanks for the update 👍

@tanthammar
Copy link
Owner

@viezel Just a thought. Try removing wire() on all nested fields and apply it only to the Repater.

Haven't tested that scenario.

Please report back if it solved it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-bug This doesn't seem like a bug
Projects
None yet
Development

No branches or pull requests

2 participants