Explorar o código

Added support for prepend text in number fields.

Alan Lam %!s(int64=8) %!d(string=hai) anos
pai
achega
05219c2944
Modificáronse 1 ficheiros con 13 adicións e 1 borrados
  1. 13 1
      engine/form.php

+ 13 - 1
engine/form.php

@@ -126,12 +126,24 @@ class Form {
 		$max = ($options->max ?? false) ? "max=\"$options->max\"" : "";
 		$max = ($options->max ?? false) ? "max=\"$options->max\"" : "";
 		$max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : "";
 		$max_length = ($options->maxLength ?? false) ? "maxlength=\"$options->maxLength\"" : "";
 		$step = $options->step ?? 1;
 		$step = $options->step ?? 1;
+		$prepend_text = $options->prependText ?? "";
 
 
 		?>
 		?>
 		<div class="row mb-1">
 		<div class="row mb-1">
 			<label class="col-sm-4 col-form-label" for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
 			<label class="col-sm-4 col-form-label" for="<?=$id?>"><?=htmlspecialchars($options->label)?></label>
 			<div class="col-sm">
 			<div class="col-sm">
-				<input class="form-control" type="number" name="<?=$options->name?>" id="<?=$id?>" placeholder="<?=htmlspecialchars($placeholder)?>" value="<?=htmlspecialchars($value)?>" step="<?=$step?>" <?=$required?> <?=$min?> <?=$max?> <?=$max_length?> />
+				<div class="input-group">
+					<?php
+					if(!empty($prepend_text)) {
+						?>
+						<div class="input-group-prepend">
+							<span class="input-group-text"><?=htmlspecialchars($prepend_text)?></span>
+						</div>
+						<?php
+					}
+					?>
+					<input class="form-control" type="number" name="<?=$options->name?>" id="<?=$id?>" placeholder="<?=htmlspecialchars($placeholder)?>" value="<?=htmlspecialchars($value)?>" step="<?=$step?>" <?=$required?> <?=$min?> <?=$max?> <?=$max_length?> />
+				</div>
 				<?php
 				<?php
 				if($help_text) {
 				if($help_text) {
 					?>
 					?>