Creating a field with defaultvalue empty throws and exception
Opened this issue · 2 comments
I tried to create a new field in a new module. I've set the field to required so it can't be empty, but if default value is not set then it throws and exception:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'defaultvalue' cannot be null (SQL: insert into `module_fields` (`colname`, `label`, `module`, `field_type`, `unique`, `defaultvalue`, `minlength`, `maxlength`, `required`, `listing_col`, `popup_vals`, `updated_at`, `created_at`) values (name, Name, 10, 22, 1, , 0, 256, 1, 1, , 2018-01-26 22:53:14, 2018-01-26 22:53:14))
This behavior is unintuitive since a required field shouldn't need a default value. If I change the constraint in the DB will this then cause issues somewhere else since NULL is not properly handled or can I go ahead and make this change?
I bypassed the issue by setting a default value text as how you'd use a placeholder text. However, when I created a HTML field there was no field for defaultvalue and so I can't work around it.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'defaultvalue' cannot be null (SQL: insert into `module_fields` (`colname`, `label`, `module`, `field_type`, `unique`, `defaultvalue`, `minlength`, `required`, `listing_col`, `popup_vals`, `updated_at`, `created_at`) values (description_long, Long Description, 11, 11, 0, , 0, 1, 0, , 2018-01-26 23:00:46, 2018-01-26 23:00:46))
I fixed it by setting the defaultvalue db constraint to allow null and now it works. Not sure if this will cause issues with unhandled null expections down the line...