MDL-53402 mod_data: Required fields can contain 0.
The number and text field would not accept 0 as a valid response.
This commit is contained in:
@@ -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) !== '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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) !== '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user