You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a field is required (since it's a not null column) and a user enters 0 for that field, an error is thrown during validation stating that the value is empty.
Steps to reproduce:
Create a table with a column that is not null, but where the default is null.
Switch to input mode and try to add a record where that value is 0.
Additional background:
The problem appears to be in the validate_data method of CustomDatabaseTables class in lib/cdbt.class.php
function validate_data($column_schema, $data) {
if ($column_schema['not_null'] && $column_schema['default'] == null) {
if (empty($data))
return array(false, __('empty', self::DOMAIN));
}
if (!empty($data)) {
This means that empty($data) will return true when $data is a string containing the number 0. In my installation I've changed the validate function to explicitly check for empty string or null which then allows me to set 0 values on input or edit.
function validate_data($column_schema, $data) {
if ($column_schema['not_null'] && $column_schema['default'] == null) {
if ($data == '' || $data == NULL)
return array(false, __('empty', self::DOMAIN));
}
if ($data != '' && $data != NULL) {
The text was updated successfully, but these errors were encountered:
Greetings, I'm using v1.10
If a field is required (since it's a not null column) and a user enters 0 for that field, an error is thrown during validation stating that the value is empty.
Steps to reproduce:
Additional background:
The problem appears to be in the
validate_data
method ofCustomDatabaseTables
class inlib/cdbt.class.php
The
empty
function returns true when $data evaluates as false. See http://php.net/manual/en/function.empty.php for more information.This means that
empty($data)
will returntrue
when$data
is a string containing the number 0. In my installation I've changed the validate function to explicitly check for empty string or null which then allows me to set 0 values on input or edit.The text was updated successfully, but these errors were encountered: