Widget DatePicker stores "null" date 0000-00-00

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”

can anyone help me?
Thanks

For the purposes of debugging, try storing the date back to a string field to see what is happening.

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?

The DB is MySql

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.

                'filter' => DatePicker::widget([
                    'model' => $searchModel,
                    'dateFormat' => 'yyyy-MM-dd',
                    'options' => ['class' => 'form-control', 'placeholder' => 'Search',],
                    'attribute' => 'oritaskduedt',
                    'clientOptions' => [
                        'autoclose' => true,
                        'format' => 'yyyy-MM-dd'
                    ],
                ]),

Thank, but i think i found the right way by reading @evstevemd’s post: $dateFormat property of class yii\i18n\Formatter does not work! - #19 by evstevemd
I’m trying…