Changeset: 22364b27b0a9 https://sourceforge.net/p/mrbs/hg-code/ci/22364b27b0a940f11b93efcbd5aa5481aa406a78 Author: Campbell Morrison <cimorri...@hg.code.sf.net> Date: Fri Apr 14 09:43:49 2017 +0100 Log message:
Handled the exceptional error case when there are no periods defined. diffstat: web/edit_area_room.php | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diffs (24 lines): diff -r f121eedfd1c6 -r 22364b27b0a9 web/edit_area_room.php --- a/web/edit_area_room.php Thu Apr 13 13:18:05 2017 +0100 +++ b/web/edit_area_room.php Fri Apr 14 09:43:49 2017 +0100 @@ -464,11 +464,18 @@ { global $periods; - foreach ($periods as $period) + // For the JavaScript to work, and MRBS to make sense, there has to be at least + // one period defined. So if for some reason, which shouldn't happen, there aren't + // any periods defined, then force there to be one by creating a single period name + // with an empty string. Because the input is a required input, then it will have + // to be saved with a period name. + $period_names = empty($periods) ? array('') : $periods; + + foreach ($period_names as $period_name) { echo "<div class=\"period_name\">\n"; echo "<label class=\"no_suffix\"></label>"; - echo "<input name=\"area_periods[]\" required value=\"" . htmlspecialchars($period) . "\">"; + echo "<input name=\"area_periods[]\" required value=\"" . htmlspecialchars($period_name) . "\">"; echo "<span class=\"delete_period\"><span>\n"; echo "</div>\n"; } ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Mrbs-commits mailing list Mrbs-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mrbs-commits