CRUDlex
CRUDlex copied to clipboard
EntityDefinition@getField $default parameter should not be null
when you submit a form and fields are not required –if the type is text– the values are an empty string. the getField function replace these empty string value by a null value which breaks the SQL schema of NOT NULL if the definition is VARCHAR
Hi, the idea of the required-flag is to reflect the NOT NULL constraint. It is called "required" due to the possibility to have non SQL-implementations. My practice is: required = true -> NOT NULL required = false -> NULLABLE Setting empty strings to NULL here is just a choice because I can't decide whether the user wants NULL or empty string with just an input field. A specific use case would be very good where this scheme breaks. I could then think about how an UI supporting the difference between null and empty string could look like.
This makes sense. My workaround is to make my custom MySQLDataFactory so I can add a ‘resetToBlank‘ function when calling ‘setValuesAndParameters’. Is there a better way?
As for a suggestion, could you make it a parameter –blank is empty string– in the MySQLDataFactory just like the useUUIDs?
Adding a flag to the field in the YAML is a good idea, I will do that. Right after the release of 0.14.0 which abstracts out the framework and then there are packages for framework implementations, Silex and Symfony for now. Reason: Silex is end of live. :(
👍 Looking forward to the release of 14.0. Any ETA?
Mainly writing documentation is left. We are currently porting a bigger project to symfony4 and as soon as this works completly, I can be sure that the abstractions are fine.