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

[Bug] nullable date in repeatable field is not working #3677

Closed
mamprogr opened this issue Apr 22, 2021 · 1 comment
Closed

[Bug] nullable date in repeatable field is not working #3677

mamprogr opened this issue Apr 22, 2021 · 1 comment
Assignees
Labels

Comments

@mamprogr
Copy link
Contributor

Bug

What I did

I have a belongsToMany relation with a pivot table. The pivot table has nullable revoked_at attribute.

image

I am using repeatable field to fill the pivot table as follows:

image

What I expected to happen

revoked_at to be set correctly.

What happened

It works fine when I enter a date but it causes the following error when I keep it empty:

SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '' for column `revoked_at` at row 1 (SQL: insert into `supervisor_course` (`course_id`, `revoked_at`, `user_id`) values (1, , 4))

What I've already tried to fix it

I tried to disable the strict mode as mentioned here, the error disappeared but the inserted value is 30/11/1899

Backpack, Laravel, PHP, DB version

When I run php artisan backpack:version the output is:

PHP VERSION:

PHP 7.4.9 (cli) (built: Aug 4 2020 11:52:41) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

LARAVEL VERSION:

v8.37.0@cf4082973abc796ec285190f0603380021f6d26f

BACKPACK VERSION:

4.1.41@44770347b918e42c052d0a138c24535b43e32472

@pxpm pxpm self-assigned this Apr 28, 2021
@pxpm
Copy link
Contributor

pxpm commented May 4, 2021

@mamprogr

Sorry for taking time to come back here.

So, you are trying to populate a BelongsToMany relation with a repeatable field, at the present moment, that is not supported unless you are using #3410 this PR.

For the moment BelongsToMany work only with selectable elements.

Otherwise you need to override your store() method in SomeEntityCrudController and do the manual saving of supervisors. https://backpackforlaravel.com/docs/4.1/crud-operation-update#callbacks-1

If you give a try to that PR and your current problem is solved by it, please let us know in the comments, it could help to speed up the merging process.

I am going to close this as I don't think there is much more we can do here, please use the current solution provided or the PR. If you think I am wrong, please re-open 👍

Wish you the best,
Pedro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants