本文整理汇总了PHP中yii\helpers\Html::textInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::textInput方法的具体用法?PHP Html::textInput怎么用?PHP Html::textInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::textInput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs the widget.
*/
public function run()
{
// Print elfinder widget in modal
Modal::begin(['toggleButton' => false, 'id' => $this->options['id'] . '-dialog', 'size' => Modal::SIZE_LARGE]);
echo ElFinder::widget(['language' => $this->language, 'controller' => $this->controller, 'path' => $this->path, 'filter' => 'image', 'callbackFunction' => new JsExpression('function(file, id){
console.log( file.url, "' . $this->buttonOptions['id'] . '" );
$("#' . $this->options['id'] . '").val( file.url );
$("#' . $this->options['id'] . '-thumb").attr("src", file.url ).show();
$("#' . $this->options['id'] . '-dialog").modal("hide");
}'), 'path' => $this->path, 'frameOptions' => ['style' => 'width: 100%; height: 500px; border: 0px;']]);
Modal::end();
// Render input and upload button
if ($this->hasModel()) {
$attr = $this->attribute;
$hidden = $this->model->{$attr} ? '' : 'display:none;';
$replace['{image}'] = '<img id="' . $this->options['id'] . '-thumb" class="thumbnail" src="' . $this->model->{$attr} . '" style="max-width: 150px; max-height: 150px; ' . $hidden . '" />';
$replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$hidden = $this->value ? '' : 'display:none;';
$replace['{image}'] = '<img id="' . $this->options['id'] . '-thumb" src="' . $this->value . '" style="max-width: 150px; max-height: 150px; ' . $hidden . '" />';
$replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
}
$replace['{button}'] = Html::tag($this->buttonTag, $this->buttonName, $this->buttonOptions);
echo strtr($this->template, $replace);
// Publish assets
AssetsCallBack::register($this->getView());
if (!empty($this->multiple)) {
$this->getView()->registerJs("\n\n mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ",\n function(files, id){\n var _f = [];\n for (var i in files) { _f.push(files[i].url); }\n \$('#' + id).val(_f.join(', ')).trigger('change');\n return true;\n });\n\n \$(document).on('click','#" . $this->buttonOptions['id'] . "',\n function(){\n mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");\n }\n );");
} else {
$this->getView()->registerJs("\n\n mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n \$('#' + id).val(file.url).trigger('change');\n return true;\n });\n\n \$(document).on('click',\n '#" . $this->buttonOptions['id'] . "',\n function(){\n //mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");\n \$('#" . $this->options['id'] . "-dialog').modal('show');\n }\n );");
}
}
示例2: run
/**
* @return string
*/
public function run()
{
$this->registerClientScript();
$options = ArrayHelper::merge($this->options, ['class' => 'form-control']);
if ($this->format) {
$options['data-date-format'] = $this->format;
}
return $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $options) : Html::textInput($this->name, $this->value, $options);
}
示例3: run
/**
* @inheritdoc
*/
public function run()
{
$view = $this->getView();
$kcfinder = KCFinderAsset::register($view);
if ($this->hasModel()) {
if (!empty($this->model->icon)) {
$this->src = $this->model->icon;
}
}
//$this->options = array_merge($this->options, ['onclick'=>'openKCFinder(this);']);
echo Html::tag('div', Html::img($this->src, ['id' => $this->widget['id'] . '-preview', 'class' => 'img-responsive']), ['class' => 'well well-sm text-center', 'style' => 'margin:5px;']);
echo '<div class="input-group">';
if ($this->hasModel()) {
echo Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
echo Html::textInput($this->name, $this->value, $this->options);
}
echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-clear"><i class="glyphicon glyphicon-remove"></i></button></span>';
echo '<span class="input-group-btn"><button type="button" class="btn btn-default btn-flat" id="' . $this->widget['id'] . '-btn-browse"><i class="glyphicon glyphicon-folder-open"></i></button></span>';
echo '</div>';
$session = Yii::$app->session;
if (!$session->has('KCFINDER')) {
$session->set('KCFINDER', ['disabled' => false, 'uploadDir' => $this->uploadDir, 'uploadURL' => $this->uploadURL]);
$htSource = __DIR__ . '/upload.htaccess';
$htDest = $kcfinder->basePath . '/conf/upload.htaccess';
copy($htSource, $htDest);
}
$this->registerJs();
}
示例4: initOptions
/**
* @throws \yii\base\InvalidConfigException
*/
protected function initOptions()
{
$this->{$this->buttonPlace} = Html::tag('span', $this->sortButtonName, ['class' => 'grid-sort-button ' . $this->buttonClass]);
$this->format = 'raw';
$this->value = function ($model, $key, $index, $widget) {
return Html::textInput($this->attribute . "[{$model->id}]", $model->{$this->attribute}, ['style' => 'width:40px; text-align:center', 'class' => 'grid-sort-input ' . $this->inputClass]);
};
}
示例5: getFormAttribs
public function getFormAttribs()
{
return ['customer' => ['type' => TabularForm::INPUT_HIDDEN, 'columnOptions' => ['hidden' => true]], 'name' => ['type' => TabularForm::INPUT_STATIC], 'measurement_type' => ['type' => TabularForm::INPUT_STATIC, 'value' => function ($m, $k, $i, $w) {
return MaterialTypes::$measurementType[$m->measurement_type];
}], 'price' => ['type' => TabularForm::INPUT_RAW, 'value' => function ($m, $k, $i, $w) {
return Html::textInput("price[" . $k . "]", CustomerMaterialPrice::getPrice($k, $this->customer), ['class' => 'form-control']);
}]];
}
示例6: renderTextInput
private function renderTextInput()
{
if ($this->state() !== self::STATE_TEXT) {
Html::addCssStyle($this->textInputOptions, 'display:none');
}
return Html::textInput(null, $this->inputValue(self::STATE_TEXT), $this->textInputOptions);
}
示例7: run
public function run()
{
$content = [];
if ($this->showAddon) {
Html::addCssClass($this->containerOptions, 'input-group');
}
if ($this->containerTag) {
$content[] = Html::beginTag($this->containerTag, $this->containerOptions);
}
if ($this->hasModel()) {
if ($this->autoPlaceholder && !$this->options['placeholder']) {
$this->options['placeholder'] = $this->model->getAttributeLabel($this->attribute);
}
$content[] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$content[] = Html::textInput($this->name, $this->value, $this->options);
}
if ($this->showAddon) {
$content[] = $this->renderInputAddon();
}
if ($this->containerTag) {
$content[] = Html::endTag($this->containerTag);
}
return implode("\n", $content);
}
示例8: run
public function run()
{
if ($this->hasModel()) {
return Html::activeTextInput($this->model, $this->attribute, $this->options);
}
return Html::textInput($this->name, $this->value, $this->options);
}
示例9: run
/**
* @inheritdoc
*/
public function run()
{
$inputId = $this->options['id'];
$hasModel = $this->hasModel();
if (array_key_exists('value', $this->options)) {
$value = $this->options['value'];
} elseif ($hasModel) {
$value = Html::getAttributeValue($this->model, $this->attribute);
} else {
$value = $this->value;
}
$options = array_merge($this->options, ['value' => $value]);
if ($hasModel) {
$output = Html::activeTextInput($this->model, $this->attribute, $options);
} else {
$output = Html::textInput($this->name, $this->value, $options);
}
if (!is_null($this->alias)) {
$clientOptions = array_merge($this->clientOptions, ['alias' => $this->alias]);
} else {
$clientOptions = array_merge($this->clientOptions, ['mask' => $this->mask]);
}
if (!array_key_exists('placeholder', $clientOptions) && array_key_exists('placeholder', $options)) {
$clientOptions['placeholder'] = $options['placeholder'];
}
$js = 'jQuery(\'#' . $inputId . '\').inputmask(' . Json::htmlEncode($clientOptions) . ');';
if (Yii::$app->getRequest()->getIsAjax()) {
$output .= Html::script($js);
} else {
$view = $this->getView();
InputMaskAsset::register($view);
$view->registerJs($js);
}
return $output;
}
示例10: run
public function run()
{
if ($this->hasModel()) {
$replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
}
$replace['{button}'] = Html::button($this->buttonName, $this->buttonOptions);
$replace['{preview}'] = Html::a($this->previewButtonName, "#" . $this->previewButtonOptions['id'] . '_popup', $this->previewButtonOptions) . '
<div id="' . $this->previewButtonOptions['id'] . '_popup" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h5 class="modal-title"><i class="fa fa-picture-o"></i> Preview</h5>
</div>
<div class="modal-body has-padding">
<img width="100%" src="' . $this->suffix . $this->model->{$this->attribute} . '">
</div>
<div class="modal-footer">
<button class="btn btn-warning" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
</div>
</div>
</div>
</div>';
echo strtr($this->template, $replace);
AssetsCallBack::register($this->getView());
if (!empty($this->multiple)) {
$this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(files, id){ var _f = []; for (var i in files) { _f.push(files[i].url); } \$('#' + id).val(_f.join(', ')); return true;}); \$('#" . $this->buttonOptions['id'] . "').click(function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
} else {
$this->getView()->registerJs("mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\r\n\t \$('#' + id).val(file.url.replace('" . $this->suffix . "', ''));\r\n\t \$('#' + id + '_preview_popup .modal-body').html('<img width=\"100%\" src=\"' + file.url + '\">'); return true;}); \$('#" . $this->buttonOptions['id'] . "').click(function(){mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");});");
}
}
示例11: renderFields
private function renderFields()
{
$rows = '';
if (count($this->_config['fieldName'])) {
foreach ($this->_config['fieldName'] as $ind => $n) {
$search = [];
$replace = [];
$t = $this->_config['fieldType'][$ind];
$r = $this->_config['fieldRequired'][$ind];
//$opt = $r ? ['required'=>true] : [];
$name = 'f' . $ind;
$label = Html::label($n) . ($r ? $this->_config['tplMarker'] : '');
$search[] = '{*label*}';
$replace[] = $label;
if ($t == 'input') {
$opt['maxlength'] = 50;
$tpl = 'tplInput';
$field = Html::textInput($name, null, $opt);
} elseif ($t == 'textarea') {
$opt['rows'] = 4;
$opt['maxlength'] = 500;
$tpl = 'tplArea';
$field = Html::textarea($name, '', $opt);
}
if (strpos($this->_config[$tpl], '{*label*}') === false && $r) {
$field .= $this->_config['tplMarker'];
}
$search[] = '{*field*}';
$replace[] = $field;
$rows .= str_replace($search, $replace, $this->_config[$tpl]) . "\n";
}
}
return $rows;
}
示例12: renderInput
/**
* Render input for formatted value
*/
protected function renderInput()
{
//Html::addCssClass($this->_inputOptions, 'form-control');
$this->addDataOptions();
$input = $this->hasModel() ? Html::activeTextInput($this->model, $this->attribute, $this->options) : Html::textInput($this->name, $this->value, $this->options);
return $input;
}
示例13: init
public function init()
{
parent::init();
$this->_inputStr = '<div class="form-group">';
if ($this->hasModel()) {
$this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
} else {
$this->_inputStr .= Html::label($this->name);
}
$this->_inputStr .= '<div id="' . Html::encode($this->name) . '" class="input-group date">';
if ($this->hasModel()) {
$value = Html::getAttributeValue($this->model, $this->attribute);
} else {
$value = $this->value;
}
if ($value !== null) {
$value = Yii::$app->formatter->asDatetime($value);
}
$options = $this->options;
$options['class'] = 'form-control';
//$options['readonly'] = '';
$options['value'] = $value;
if ($this->hasModel()) {
$this->_inputStr .= Html::activeTextInput($this->model, $this->attribute, $options);
} else {
$this->_inputStr .= Html::textInput($this->name, $this->value, $options);
}
$this->_inputStr .= '<span class="input-group-addon">
<span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
';
}
示例14: run
/**
* @inheritdoc
*/
public function run()
{
if (empty($this->data) || !is_array($this->data)) {
throw new InvalidConfigException("You must define the 'data' property");
}
$this->registerAssets();
echo Html::tag('div', Html::textInput($this->name, $this->value, $this->options), $this->container);
}
示例15: renderWidget
/**
* Renders the Spinner widget.
* @return string the rendering result.
*/
public function renderWidget()
{
if ($this->hasModel()) {
return Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
return Html::textInput($this->name, $this->value, $this->options);
}
}