Updated the validation of the width and height for the customcert page
This commit is contained in:
parent
7781024377
commit
f2314ad49e
2 changed files with 8 additions and 6 deletions
|
@ -148,16 +148,18 @@ class mod_customcert_edit_form extends moodleform {
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
if (strpos($key, 'width_') !== false) {
|
if (strpos($key, 'width_') !== false) {
|
||||||
$page = str_replace('width_', '', $key);
|
$page = str_replace('width_', '', $key);
|
||||||
|
$widthid = 'width_' . $page;
|
||||||
// Validate that the width is a valid value.
|
// Validate that the width is a valid value.
|
||||||
if (!isset($data['width_' . $page]) || !is_number($data['width_' . $page])) {
|
if ((!isset($data[$widthid])) || (!is_numeric($data[$widthid])) || ($data[$widthid] <= 0)) {
|
||||||
$errors['width_' . $page] = get_string('widthnotvalid', 'customcert');
|
$errors[$widthid] = get_string('widthnotvalid', 'customcert');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strpos($key, 'height_') !== false) {
|
if (strpos($key, 'height_') !== false) {
|
||||||
$page = str_replace('height_', '', $key);
|
$page = str_replace('height_', '', $key);
|
||||||
|
$heightid = 'height_' . $page;
|
||||||
// Validate that the height is a valid value.
|
// Validate that the height is a valid value.
|
||||||
if (!isset($data['height_' . $page]) || !is_number($data['height_' . $page])) {
|
if ((!isset($data[$heightid])) || (!is_numeric($data[$heightid])) || ($data[$heightid] <= 0)) {
|
||||||
$errors['height_' . $page] = get_string('heightnotvalid', 'customcert');
|
$errors[$heightid] = get_string('heightnotvalid', 'customcert');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ $string['fontsize'] = 'Size';
|
||||||
$string['fontsize_help'] = 'The size of the font in points.';
|
$string['fontsize_help'] = 'The size of the font in points.';
|
||||||
$string['getcustomcert'] = 'Get your custom certificate';
|
$string['getcustomcert'] = 'Get your custom certificate';
|
||||||
$string['height'] = 'Height';
|
$string['height'] = 'Height';
|
||||||
$string['heightnotvalid'] = 'The height has to be a valid number.';
|
$string['heightnotvalid'] = 'The height has to be a valid number greater than 0.';
|
||||||
$string['height_help'] = 'This is the height of the certificate PDF in mm. For reference an A4 piece of paper is 297mm high and a letter is 279mm high.';
|
$string['height_help'] = 'This is the height of the certificate PDF in mm. For reference an A4 piece of paper is 297mm high and a letter is 279mm high.';
|
||||||
$string['invalidcolour'] = 'Invalid colour chosen, please enter a valid HTML colour name, or a six-digit, or three-digit hexadecimal colour.';
|
$string['invalidcolour'] = 'Invalid colour chosen, please enter a valid HTML colour name, or a six-digit, or three-digit hexadecimal colour.';
|
||||||
$string['invalidposition'] = 'Please select a positive number for position {$a}.';
|
$string['invalidposition'] = 'Please select a positive number for position {$a}.';
|
||||||
|
@ -71,5 +71,5 @@ $string['summaryofissue'] = 'Summary of issue';
|
||||||
$string['uploadimage'] = 'Upload image';
|
$string['uploadimage'] = 'Upload image';
|
||||||
$string['viewcustomcertissues'] = 'View {$a} issued custom certificates';
|
$string['viewcustomcertissues'] = 'View {$a} issued custom certificates';
|
||||||
$string['width'] = 'Width';
|
$string['width'] = 'Width';
|
||||||
$string['widthnotvalid'] = 'The width has to be a valid number.';
|
$string['widthnotvalid'] = 'The width has to be a valid number greater than 0.';
|
||||||
$string['width_help'] = 'This is the width of the certificate PDF in mm. For reference an A4 piece of paper is 210mm wide and a letter is 216mm wide.';
|
$string['width_help'] = 'This is the width of the certificate PDF in mm. For reference an A4 piece of paper is 210mm wide and a letter is 216mm wide.';
|
||||||
|
|
Loading…
Reference in a new issue