How to insert date values into the database with Grocery CRUD Enterprice

Can you help me how to insert date values into the database? For example, today is October 9, 2023 but I want to select the value October 20, 2023 into the database, what should I do? While in Grocery CRUD Enterprise, the add form does not allow datepicker input, giving me a choice as shown in the attached image.

Hello @phamtungvnp ,

Can you send us the function on your Controller that you use? Date fields should work out of the box. Also maybe try fieldType to add native_date instead?

Regards
Johnny

Here is my Controller:


Problem with me is in the ADD and EDIT form, Grocery CRUD don’t show any input type (date picker). I don’t know what is the next step. !

Hello @phamtungvnp ,

Seems that you are missing the fieldType from what I see from your code. For example:

$crud->fieldType('ngaynhan_dukien', 'datetime');

If this still doesn’t work for you then try:

$crud->fieldType('ngaynhan_dukien', 'native_datetime');

Regards
Johnny

Hello @johnny
The above code helped me solve the problem. Thank you very much.

1 Like