Просмотр исходного кода

Add minimum length requirements for staff description fields

Alan Lam 2 лет назад
Родитель
Сommit
92433f0131
2 измененных файлов с 7 добавлено и 3 удалено
  1. 2 1
      engine/form.php
  2. 5 2
      json/age_verification_greene_king.json

+ 2 - 1
engine/form.php

@@ -355,6 +355,7 @@ class Form {
 		$value = $options->value ?? http::value($options->name);
 		$required = ($options->required ?? false) ? "required" : "";
 		$help_text = $options->helpText ?? false;
+		$min_length = ($options->minLength ?? false) ? "minlength=\"$options->minLength\"" : "";
 		$max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : "";
 		$requirements = $options->requirements ?? [];
 		$required_if_valid = !empty($options->requiredIfValid) ? "true" : "false";
@@ -366,7 +367,7 @@ class Form {
 				self::renderRequiredBadge($required);
 				?>
 			</label>
-			<textarea class="form-control" name="<?=$options->name?>" id="<?=$id?>" placeholder="Enter text" rows="4" <?=$required?> <?=$max_length?>><?=htmlspecialchars($value)?></textarea>
+			<textarea class="form-control" name="<?=$options->name?>" id="<?=$id?>" placeholder="Enter text" rows="4" <?=$required?> <?=$min_length?> <?=$max_length?>><?=htmlspecialchars($value)?></textarea>
 			<?php
 			if($help_text) {
 				?>

+ 5 - 2
json/age_verification_greene_king.json

@@ -100,8 +100,10 @@
 			"type": "textarea",
 			"name": "challenge_description",
 			"label": "Describe the test from start to finish",
+			"minLength": 50,
 			"maxLength": 400,
-			"helpText": "Describe how the challenge took place. For example: \"While entering I was approached politely and asked for ID.\""
+			"required": true,
+			"helpText": "Describe how the challenge took place. Please enter at least 50 characters. For example: \"While entering I was approached politely and asked for ID.\""
 		},
 		{
 			"type": "hr"
@@ -129,8 +131,9 @@
 			"type": "textarea",
 			"name": "challenger_description",
 			"label": "Descriptions of staff and their locations/interactions",
+			"minLength": 50,
 			"maxLength": 250,
-			"helpText": "Describe ANY members of staff that you saw in the venue and any comments you feel that are relevant. Please add an accurate description of any staff members you saw even if not challenged. For example: \"She was about 150cm tall and had long red hair and glasses. She approached me and asked me if I wanted some water and then asked if I had any ID.\"",
+			"helpText": "Describe ANY members of staff that you saw in the venue and any comments you feel that are relevant. Please add an accurate description of any staff members you saw even if not challenged. Please enter at least 50 characters. For example: \"She was about 150cm tall and had long red hair and glasses. She approached me and asked me if I wanted some water and then asked if I had any ID.\"",
 			"customerExport": false,
 			"required": true
 		},