Skip to content

Updates not applied when 'resolveUsing' is called #35

@medteck

Description

@medteck

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions