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

Added support for step in number fields.

Alan Lam 8 лет назад
Родитель
Сommit
4c5951d67e
2 измененных файлов с 11 добавлено и 6 удалено
  1. 2 1
      engine/form.php
  2. 9 5
      json/bacta.json

+ 2 - 1
engine/form.php

@@ -125,12 +125,13 @@ class Form {
 		$min = ($options->min ?? false) ? "min=\"$options->min\"" : "";
 		$max = ($options->max ?? false) ? "max=\"$options->max\"" : "";
 		$max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : "";
+		$step = $options->step ?? 1;
 
 		?>
 		<div class="row mb-1">
 			<label class="col-sm-4 col-form-label" for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
 			<div class="col-sm">
-				<input class="form-control" type="number" name="<?=$options->name?>" id="<?=$id?>" placeholder="<?=htmlspecialchars($placeholder)?>" value="<?=htmlspecialchars($value)?>" step="0.01" <?=$required?> <?=$min?> <?=$max?> <?=$max_length?> />
+				<input class="form-control" type="number" name="<?=$options->name?>" id="<?=$id?>" placeholder="<?=htmlspecialchars($placeholder)?>" value="<?=htmlspecialchars($value)?>" step="<?=$step?>" <?=$required?> <?=$min?> <?=$max?> <?=$max_length?> />
 				<?php
 				if($help_text) {
 					?>

+ 9 - 5
json/bacta.json

@@ -105,7 +105,7 @@
 			"type": "number",
 			"name": "play_jackpot",
 			"label": "Jackpot Value",
-			"maxLength": 50,
+			"maxLength": 10,
 			"min": 1,
 			"max": 20000
 		},
@@ -113,21 +113,25 @@
 			"type": "number",
 			"name": "play_machine_stake",
 			"label": "Stake Played",
-			"maxLength": 20,
+			"maxLength": 10,
 			"min": 0,
+			"step": 0.01,
 			"helpText": "This is how much the machine charges you per spin."
 		},
 		{
-			"type": "number",
+			"type": "dropdown",
 			"name": "play_minutes",
 			"label": "Time Played (Minutes)",
-			"maxLength": 50
+			"values": ["", "1", "2", "3", "4", "5"],
+			"displayStrings": ["Did not play/Don't know", "1 minute", "2 minutes", "3 minutes", "4 minutes", "5 minutes or more"]
 		},
 		{
 			"type": "number",
 			"name": "play_spent",
 			"label": "Total Spent",
-			"maxLength": 50
+			"maxLength": 10,
+			"min": 0,
+			"step": 0.01
 		},
 
 		{