Yii Framework Forum

'date' input type not inserted correctly into database MariaDB

(SomebodyHere) #1

I’m working with the user signup form in the yii2-advanced template. I added a field named “dob” and the code for that in /frontend/views/signup.php looks like this:
<?= $form->field($model, 'dob')->input('date') ?>
In SignupForm.php ‘dob’ is set to ‘required’ and is 'trim’med.

I tried out the form and everything works correctly except for the ‘dob’ value. In my database (I’m using MariaDB) the value is stored as 0000-00-00 while I (obviously) entered a different value. I can’t figure out what’s wrong…

(Mehdi Achour) #2

Usually, in this cases:

  1. Check the data being sent to your controller (var_dump(Yii::$app->request->post());
    Is dob present ? In what format does it come ?

  2. Check the SQL query being performed in the debug bar. Does it look right?

  3. Re-check your MariaDb structure (SHOW CREATE user). Is the field there ? Is its type correct ?