public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->value; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $output = Form::number($this->name, $this->value, $this->attributes); break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
public function build() { $output = ""; if (parent::build() === false) { return; } switch ($this->status) { case "disabled": case "show": if ($this->type == 'hidden' || $this->value == "") { $output = ""; } elseif (!isset($this->value)) { $output = $this->layout['null_label']; } else { $output = $this->value; } $output = "<div class='help-block'>" . $output . " </div>"; break; case "create": case "modify": $lower = Form::number($this->name . '[]', @$this->values[0], $this->attributes); $upper = Form::number($this->name . '[]', @$this->values[1], $this->attributes); $output = ' <div id="range_' . $this->name . '_container"> <div class="input-group"> <div class="input-group-addon">≥</div> ' . $lower . ' </div> <div class="input-group"> <div class="input-group-addon">≤</div> ' . $upper . ' </div> </div>'; break; case "hidden": $output = Form::hidden($this->name, $this->value); break; default: } $this->output = "\n" . $output . "\n" . $this->extra_output . "\n"; }
/** * Render html of field. * * @return string */ public function render() { $attrs = array(); $id = $this->getHtmlId(); $name = $this->getHtmlName(); $value = $this->getValue(); $label = $this->getLabel(); $cssClass = 'number form-control'; $errorMessage = ''; $attrs['id'] = $id; if (!$this->isValid) { $errorMessage = sprintf("<span class='error'>%s</span>", $this->getErrorMessage()); $cssClass .= ' error'; } $defaultValue = $this->getOption('default_value'); if (!strlen($value)) { $value = $defaultValue; } if ($this->getOption('required') == 'true') { $cssClass .= ' required'; } if ($this->getOption('placeholder')) { $attrs['placeholder'] = $this->getOption('placeholder'); } if ($this->getOption('min_value')) { $attrs['min'] = $this->getOption('min_value'); } if ($this->getOption('max_value')) { $attrs['max'] = $this->getOption('max_value'); } $attrs['class'] = $cssClass; $html = ''; if (!empty($label)) { $html .= FormFacade::label($label); } $html .= FormFacade::number($name, $value, $attrs) . $errorMessage; $html = sprintf($this->htmlItemTemplate, $html); return $html; }
protected function renderEditable() : string { return FormFacade::number($this->elementName(), $this->getCurrentValue(), ['id' => $this->elementId(), 'class' => 'form-control', 'min' => $this->min, 'max' => $this->max, 'step' => $this->step]); }