diff --git a/mod/data/edit.php b/mod/data/edit.php
index 7350ccad302..564da864eab 100644
--- a/mod/data/edit.php
+++ b/mod/data/edit.php
@@ -268,6 +268,9 @@ if ($datarecord = data_submitted() and confirm_sesskey()) {
'rid' => $recordid,
));
redirect($viewurl);
+ } else if (!empty($datarecord->saveandadd)) {
+ // User has clicked "Save and add another". Reset all of the fields.
+ $datarecord = null;
}
}
}
@@ -354,7 +357,7 @@ if ($rid) {
echo ' ';
} else {
if ((!$data->maxentries) || has_capability('mod/data:manageentries', $context) || (data_numentries($data) < ($data->maxentries - 1))) {
- echo ' ';
+ echo ' ';
}
}
echo '';
diff --git a/mod/data/tests/behat/add_entries.feature b/mod/data/tests/behat/add_entries.feature
index 2e9ad77d454..496bbdbcfd4 100644
--- a/mod/data/tests/behat/add_entries.feature
+++ b/mod/data/tests/behat/add_entries.feature
@@ -52,6 +52,7 @@ Feature: Users can add entries to database activities
And I add an entry to "Test database name" database with:
| Test field name | Student second entry |
And I press "Save and add another"
+ And the field "Test field name" does not match value "Student second entry"
And I add an entry to "Test database name" database with:
| Test field name | Student third entry |
And I press "Save and view"