TbHtml::textField PHP Method

textField() public static method

Generates a text field input.
See also: self::textInputField
public static textField ( string $name, string $value = '', array $htmlOptions = [] ) : string
$name string the input name.
$value string the input value.
$htmlOptions array additional HTML attributes.
return string the generated input field.
    public static function textField($name, $value = '', $htmlOptions = array())
    {
        return self::textInputField('text', $name, $value, $htmlOptions);
    }

Usage Example

 /**
  * Runs the widget.
  */
 public function run()
 {
     list($name, $id) = $this->resolveNameID();
     $id = $this->resolveId($id);
     if ($this->hasModel()) {
         echo TbHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
     } else {
         echo TbHtml::textField($name, $this->value, $this->htmlOptions);
     }
     if ($this->assetPath !== false) {
         $this->publishAssets($this->assetPath);
         $this->registerCssFile('/css/bootstrap-datetimepicker.css');
         if ($this->registerJs) {
             $this->registerScriptFile('/js/' . $this->resolveScriptVersion('bootstrap-datetimepicker.js'), CClientScript::POS_END);
             if (isset($this->locale)) {
                 $this->locale = str_replace('_', '-', $this->locale);
                 $this->registerScriptFile("/js/locales/bootstrap-datetimepicker.{$this->locale}.js", CClientScript::POS_END);
             }
         }
     }
     if ($this->bindPlugin) {
         $options = !empty($this->pluginOptions) ? CJavaScript::encode($this->pluginOptions) : '';
         $this->getClientScript()->registerScript(__CLASS__ . '#' . $id, "jQuery('#{$id}').datetimepicker({$options});");
     }
 }
All Usage Examples Of TbHtml::textField
TbHtml