|
@@ -8,14 +8,19 @@ class Number extends Text
|
|
|
'@number-input',
|
|
|
];
|
|
|
|
|
|
- protected $default = 0;
|
|
|
+ /**
|
|
|
+ * Width for label and field.
|
|
|
+ *
|
|
|
+ * @var array
|
|
|
+ */
|
|
|
+ protected $width = [
|
|
|
+ 'label' => 4,
|
|
|
+ 'field' => 2,
|
|
|
+ ];
|
|
|
|
|
|
public function render()
|
|
|
{
|
|
|
- $this->default($this->default);
|
|
|
-
|
|
|
$this->script = <<<JS
|
|
|
-
|
|
|
$('{$this->getElementClassSelector()}:not(.initialized)')
|
|
|
.addClass('initialized')
|
|
|
.bootstrapNumber({
|
|
@@ -30,11 +35,6 @@ JS;
|
|
|
return parent::render();
|
|
|
}
|
|
|
|
|
|
- protected function prepareInputValue($value)
|
|
|
- {
|
|
|
- return (int) $value;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Set min value of number field.
|
|
|
*
|
|
@@ -62,4 +62,30 @@ JS;
|
|
|
|
|
|
return $this;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param mixed $value
|
|
|
+ *
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
+ protected function prepareInputValue($value)
|
|
|
+ {
|
|
|
+ return (int) $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set or get value of the field.
|
|
|
+ *
|
|
|
+ * @param null $value
|
|
|
+ *
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ public function value($value = null)
|
|
|
+ {
|
|
|
+ if (is_null($value)) {
|
|
|
+ return (int) parent::value();
|
|
|
+ }
|
|
|
+
|
|
|
+ return parent::value($value);
|
|
|
+ }
|
|
|
}
|