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

Usage of Checkboxes field

Open pktharindu opened this issue 5 years ago • 0 comments

I'm trying to use the included Checkboxes field in another nova resource and I can't figure out how the options should be passed. Currently, my field looks like something like this which doesn't work:

Checkboxes::make(__('Foods'), 'foods')
    ->withGroups()
    ->options(collect(config('foods'))->map(function ($food, $key) {
        return [
             'group'  => ucfirst($food['group']),
             'option' => $key,
             'label'  => $food['name'],
        ];
    })->groupBy('group')->toArray()),

My config file looks something like this:

<?php

return [
    'apple' => [
        'name' => 'Apple',
        'group' => 'Fruit',
    ],

    'orange' => [
        'name' => 'Orange',
        'group' => 'Fruit',
    ],
    ...
];

Can you please show me how I should structure the config file and/or fields options to make this work?

pktharindu avatar Mar 22 '19 18:03 pktharindu