diff --git a/mod/data/field/number/field.class.php b/mod/data/field/number/field.class.php index 4035f501c98..da797ccba12 100644 --- a/mod/data/field/number/field.class.php +++ b/mod/data/field/number/field.class.php @@ -94,6 +94,16 @@ class data_field_number extends data_field_base { return $DB->sql_cast_char2real($fieldname, true); } + /** + * Check if a field from an add form is empty + * + * @param mixed $value + * @param mixed $name + * @return bool + */ + function notemptyfield($value, $name) { + return strval($value) !== ''; + } } diff --git a/mod/data/field/text/field.class.php b/mod/data/field/text/field.class.php index 90aee4c8d1d..9489db71f3b 100644 --- a/mod/data/field/text/field.class.php +++ b/mod/data/field/text/field.class.php @@ -43,6 +43,16 @@ class data_field_text extends data_field_base { return array(" ({$tablealias}.fieldid = {$this->field->id} AND ".$DB->sql_like("{$tablealias}.content", ":$name", false).") ", array($name=>"%$value%")); } + /** + * Check if a field from an add form is empty + * + * @param mixed $value + * @param mixed $name + * @return bool + */ + function notemptyfield($value, $name) { + return strval($value) !== ''; + } } diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php index 5101a924fbd..cc6f395ce15 100644 --- a/mod/data/field/textarea/field.class.php +++ b/mod/data/field/textarea/field.class.php @@ -270,7 +270,8 @@ class data_field_textarea extends data_field_base { $names = explode('_', $name); // Clean first. if (count($names) == 2) { - return !empty($value); + // Don't assume that this is coming from a text editor with tags. + return strval($value) !== ''; } return false; }