Current Path : /data/web/virtuals/51568/virtual/www/subdom/pomucky/src/form/ |
Current File : /data/web/virtuals/51568/virtual/www/subdom/pomucky/src/form/InputField.php |
<?php namespace app\form; use app\Model; class InputField extends BaseField { public const TYPE_TEXT = 'text'; public const TYPE_PASSWORD = 'password'; public const TYPE_NUMBER = 'number'; public const TYPE_DATETIME_LOCAL = 'datetime-local'; public const TYPE_EMAIL = 'email'; public const TYPE_HIDDEN = 'hidden'; public $isType = self::TYPE_TEXT; public function changeType(string $type) { $this->isType = constant('self::'. $type); return $this; } public function renderInput(): string { return sprintf('<input type="%s" id="%s" name="%s" step="any" value="%s" class="form-control rounded-0 %s" %s >', $this->isType, $this->attribute, $this->attribute, $this->model->{$this->attribute}, $this->model->hasError($this->attribute) ? 'is-invalid' : '', isset($this->model->disabled[$this->attribute]) && $this->model->disabled[$this->attribute] ? "disabled" : "" ); } }