Merge branch 'wip-MDL-53402-30' of git://github.com/abgreeve/moodle into MOODLE_30_STABLE

This commit is contained in:
Dan Poltawski
2016-05-02 17:06:26 +01:00
4 changed files with 44 additions and 1 deletions
+10
View File
@@ -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) !== '';
}
}
+10
View File
@@ -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) !== '';
}
}
+2 -1
View File
@@ -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;
}
@@ -225,3 +225,25 @@ Feature: Users can be required to specify certain fields when adding entries to
And I press "Save and view"
Then ".alert.alert-error" "css_element" should exist in the "Required Latlong" "table_row"
And ".alert.alert-error" "css_element" should exist in the "Not required Latlong" "table_row"
Scenario: A student filling in number and text fields with zero will not see an error.
Given I log in as "student1"
And I follow "Course 1"
When I add an entry to "Test database name" database with:
| Base Text input | Some input to allow us to submit the otherwise empty form |
| Required Checkbox Option 1 | 1 |
| RTOC Option 1 | 1 |
| Latitude | 0 |
| Longitude | 0 |
| Required Menu | 1 |
| Required Number | 0 |
| Required Radio Option 1 | 1 |
| Required Text input | 0 |
| Required Text area | 0 |
| Required URL | http://example.com/ |
| Required Multimenu | 1 |
| Required Two-Option Multimenu | 1 |
And I press "Save and view"
And I follow "View list"
Then I should not see "No entries in database"
And I should see "Some input to allow us to submit the otherwise empty form"