If I insert in a form any date in a date field with yii\jui\DatePicker in the database it ends up with the following “null” date “0000-00-00”: <?= $form->field($model, 'dataSentenza')->widget(DatePicker::classname(), ['language' => 'it']) ?>
If instead I change the code like this : <?= $form->field($model, 'dataSentenza')->widget(DatePicker::classname(), ['language' => 'it'], 'dateFormat' => 'yyyy-MM-dd') ?>
despite being the correct date format of the DB, the following validation error is returned: “The format of Data Sentenza is invalid”
I changed the data type in the DB structure by setting it to string, as you suggested: now the problem has disappeared, the correct date ends up in the DB …
I didn’t understand why it didn’t work before but at least now I have a more acceptable solution, thanks
The change to string field was only to debug the issue. Now try inserting the date string using native SQL into the database and likely you will reproduce the original error. Then you can tweak the input until database insert accepts the correct format - then back to modifying the format on the application to match what the database accepts. What database are you using?
Check the Debug window and see how the SQL is inserted. Below is a code snippets you may find useful. This is using DatePicker in the Grid Search box (below). Try experimenting with clientOptions as below.