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

Updates not applied when 'resolveUsing' is called #35

Open
medteck opened this issue Aug 20, 2020 · 0 comments
Open

Updates not applied when 'resolveUsing' is called #35

medteck opened this issue Aug 20, 2020 · 0 comments

Comments

@medteck
Copy link

medteck commented Aug 20, 2020

When using this code:

Checkboxes::make(trans_choice('Attribute', 2), 'product_attributes')
                ->options(\App\Models\Tenants\Products\Attribute::pluck('label', 'id')->toArray())
                ->resolveUsing(fn() => $this->resource->attributes()->get()->implode('id', ','))
                ->hideFromIndex(),

It shows checkboxes properly with the right values in details and editing page as well. But After checking/unchecking some checkboxes, changes are not applied.

A workaround is using displayUsing instead and the new code is :

Checkboxes::make(trans_choice('Attribute', 2), 'product_attributes')
                ->options(\App\Models\Tenants\Products\Attribute::pluck('label', 'id')->toArray())
                ->displayUsing(fn() => $this->resource->attributes()->get()->implode('id', ','))
                ->hideFromIndex(),

In this case, changes are applied but since displayUsing is only used by nova in details page, and not in editing page. Checkboxes are not checked by default in editing page.

Thanks,

@medteck medteck changed the title Updates not applied when using 'resolveUsing' Updates not applied when 'resolveUsing' is called Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant