Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3k stars 880 forks source link

Date field allow nullable save #5515

Closed raviroshanmehta closed 2 months ago

raviroshanmehta commented 2 months ago

CURD Field type date is not allowing to save null value.

I have a column in database which is nullable in migration definition. Until I don't save value it's working as expected but after saving value i don't have any option to save it NULL again.

CRUD::field('expiry')->type('date')->allows_null(true);

I was expecting by passing allows_null(true) it should allow me to save null again in database but it's neither throwing any error nor allowing me to empty pre filled value.

Please let me know how can i do this ?

welcome[bot] commented 2 months ago

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

-- Justin Case The Backpack Robot

karandatwani92 commented 2 months ago

Hey @raviroshanmehta

The date field uses the browser's date picker. A few browsers come with a clear button, and others don't. For example, Google Chrome. Screenshot 2024-05-02 at 5 32 39 PM

If you want a clear button on every browser, go for the date_picker field.

CRUD::field('expiry')->type('date_picker')->date_picker_options(['clearBtn'=>true]);

This will give you a clear button and many other customization possibilities.