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

what is the right way to pass the selected checkboxes to the field ? #36

Open
romaldyminaya opened this issue Sep 11, 2020 · 1 comment

Comments

@romaldyminaya
Copy link

I'm trying to pass the value throuh a getter method but when I'm pressing the saving, an javascript exception comes out.

Here is some screen shots:

In my model:
image

The resource:
image

The exception when checkbox is clicked:
image

Thanks in advance :)

@dniccum
Copy link

dniccum commented Jan 19, 2021

@romaldyminaya I had to use the resolveUsing callback to format the information in a way that the field could parse it. I am using the bensampo/enum package to store some bitwise/flagged permissions, so I needed to change how the field was resolving the values.

Checkboxes::make(__('Permissions'), 'permissions')
                ->options($options)
                ->required()
                ->resolveUsing(function($value) {
                    $permissions = ApiKeyPermissions::flags($value);
                    return collect($permissions->getFlags())
                        ->map(function($flag) {
                            return (string) $flag->value;
                        });
                })
                ->columns(3),

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

2 participants