-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrapFormFieldNumber.class.php
executable file
·35 lines (30 loc) · 1.28 KB
/
BootstrapFormFieldNumber.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
namespace ui;
require_once(__DIR__ . '/BootstrapFormField.class.php');
/*
This class extends BootstrapFormField class to implement view() function for text input.
*/
class BootstrapFormFieldNumber extends BootstrapFormField{
public $min = null;
public $max = null;
public $step = null;
public function __construct($id = null, $label = null, $value = null){
$this->addClass('form-control');
parent::__construct($id, $label, $value);
}
public function view(){
$str = "<input type='number' ";
$str .= ( !empty($this->class) ? "class='" . implode(' ', $this->class) . "' " : "");
$str .= ( !empty($this->id) ? "id='" . $this->id . "' name='" . $this->id . "' " : "");
$str .= ( strlen($this->value) > 0 ? "value='" . $this->value . "' " : "");
$str .= ( !empty($this->placeholder) ? "placeholder='" . $this->label . "' " : "");
$str .= ( !is_null($this->min) ? "min='" . $this->min . "' " : "");
$str .= ( !is_null($this->max) ? "max='" . $this->max . "' " : "");
$str .= ( !is_null($this->step) ? "step='" . $this->step . "' " : "");
$str .= ( !empty($this->style) ? "style='" . $this->style . "' " : "");
$str .= ( $this->isDisabled ? "disabled " : "" );
$str .= ( !empty($this->additionalAttr) ? $this->additionalAttr . " " : "");
$str .= "/>";
return $str;
}
}