nova-settings icon indicating copy to clipboard operation
nova-settings copied to clipboard

Supporting the repeater field

Open graphem opened this issue 2 years ago • 2 comments

Hi! Great package, love it so far.

I am trying to make the Nova repeater field work, it seems to work at first and the data is saved, however, it is not parse back right when trying to edit, so it shows up as empty in the nova UI, but still in the DB.

Could be an issue with preparing the data back since it is a json field inside the json field.

Also I have a similar issue with the multiselect, the value are not preserved when editing back.

Thanks a lot!

graphem avatar Dec 06 '23 16:12 graphem

Hi, @graphem Pls send me code example

stepanenko3 avatar Mar 20 '24 10:03 stepanenko3

If you have your model that inherits from \Stepanenko3\NovaSettings\Models\Settings

then you have to add array casting to a model that you use as a resource in NOVA:

    protected $casts = [
        'fields' => 'array',
        'settings' => 'array',
    ];

so you will get

class Settings extends \Stepanenko3\NovaSettings\Models\Settings
{
    use HasFactory;
    use LogsActivity;

    protected $casts = [
        'fields' => 'array',
        'settings' => 'array',
    ];

}

makowskid avatar Apr 27 '24 11:04 makowskid