Datetime Field Type default_value "now" shows invalid value
Created 7 years ago by sumentuten

I can't seem to set a default value for the datetime fieldtype. Here is the config I set for the fieldtype:

'date_received' => [ 'type' => 'anomaly.field_type.datetime', 'config' => [ 'default_value' => "now", 'mode' => 'date', ], ], ]

shows error:

SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'date_received' (SQL: alter table laundrylab_laundrylab_orders add date_received date not null default 'now')

ryanthompson  —  7 years ago Best Answer

This should probably be accounted for in the schema builder for this FT but.. I would not put the defualt value there but instead where you define the fields - override the default value (from null) there instead. This way it's not trying to modify the column in that way.

I've made an issue to track the issue as well:

sumentuten  —  7 years ago

Got it. Will do it that way, instead. Thanks!