MDL-53402 mod_data: Added custom validation code for data fields.
Added custom validation to radiobutton, menu, and checkbox.
This commit is contained in:
@@ -233,7 +233,7 @@ class data_field_checkbox extends data_field_base {
|
||||
function notemptyfield($value, $name) {
|
||||
$found = false;
|
||||
foreach ($value as $checkboxitem) {
|
||||
if (!empty($checkboxitem)) {
|
||||
if (strval($checkboxitem) !== '') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -117,4 +117,15 @@ class data_field_menu extends data_field_base {
|
||||
return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", 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) !== '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,5 +116,15 @@ class data_field_radiobutton extends data_field_base {
|
||||
return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", 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) !== '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user