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

Problem with saving checkboxes #115

Closed
timdiels1 opened this issue Sep 19, 2016 · 1 comment
Closed

Problem with saving checkboxes #115

timdiels1 opened this issue Sep 19, 2016 · 1 comment

Comments

@timdiels1
Copy link

Bug Description

In Laravel v 5.3 saving an item with a checkbox fails when leaving the checkbox empty because the database column does not allow nullable values.

Fix

On the storeCRUD and updateCRUD in the CrudController we need to change the code that is changing empty (also '0' string) to null.

So we need to go from:

if (empty($value)) {
    $request->request->set($key, null);
}

to

if (empty($value) && $value !== '0') {
    $request->request->set($key, null);
}

Note: I have tested this only on MySQL, and not on other databases, but I don't think this should cause issues.

@tabacitu
Copy link
Member

You're totally right, @timdiels1

Thanks for the fix, I've implemented it.

Cheers to you! Keep 'em coming!

This was referenced Apr 2, 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

2 participants