本文整理汇总了PHP中yii\helpers\Html::activeTextInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::activeTextInput方法的具体用法?PHP Html::activeTextInput怎么用?PHP Html::activeTextInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::activeTextInput方法的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: render
/**
* @inheritDoc
*/
public function render($content = null)
{
if ($content === null) {
if (!isset($this->parts['{beginWrapper'])) {
$options = $this->wrapperOptions;
$tag = ArrayHelper::remove($options, 'tag', 'div');
$this->parts['{beginWrapper}'] = Html::beginTag($tag, $options);
$this->parts['{endWrapper}'] = Html::endTag($tag);
}
if ($this->label === false) {
$this->parts['{label}'] = '';
$this->parts['{beginLabel}'] = '';
$this->parts['{labelTitle}'] = '';
$this->parts['{endLabel}'] = '';
} elseif (!isset($this->parts['{beginLabel'])) {
$this->parts['{beginLabel}'] = Html::beginTag('label', $this->labelOptions);
$this->parts['{endLabel}'] = Html::endTag('label');
$attribute = Html::getAttributeName($this->attribute);
$this->parts['{labelTitle}'] = Html::encode($this->label ? $this->label : $this->model->getAttributeLabel($attribute));
}
if ($this->inputTemplate) {
$input = isset($this->parts['{input}']) ? $this->parts['{input}'] : Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
$this->parts['{input}'] = strtr($this->inputTemplate, ['{input}' => $input]);
}
}
return parent::render($content);
}
示例4: render
public function render($content = null)
{
$this->inputOptions['name'] = '';
if ($content === null) {
if (!isset($this->parts['{input}'])) {
// $this->inputOptions['data-bind'] = sprintf('value: %s', $this->attribute);
$this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
}
if (!isset($this->parts['{hidden}'])) {
$this->parts['{hidden}'] = Html::activeHiddenInput($this->model, $this->attribute, $this->hiddenOptions);
}
if (!isset($this->parts['{label}'])) {
$this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
}
if (!isset($this->parts['{error}'])) {
$this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
}
if (!isset($this->parts['{hint}'])) {
$this->parts['{hint}'] = '';
}
$content = strtr($this->template, $this->parts);
} elseif (!is_string($content)) {
$content = call_user_func($content, $this);
}
return empty($content) ? '' : ($this->wrapper ? $this->begin() . "\n" . $content . "\n" . $this->end() : $content);
}
示例5: 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();
}
示例6: 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;
}
示例7: render
public function render($content = null)
{
if ($content === null) {
if (!isset($this->parts['{input}'])) {
$this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->inputOptions);
}
if (!isset($this->parts['{label}'])) {
$labelsHelp = $this->model->attributeHints();
if (isset($labelsHelp[$this->attribute])) {
$this->labelOptions['label'] = '<span data-toggle="tooltip" title="" data-original-title="';
$this->labelOptions['label'] .= Html::encode($labelsHelp[$this->attribute]);
$this->labelOptions['label'] .= '">';
$this->labelOptions['label'] .= Html::encode($this->model->getAttributeLabel($this->attribute));
$this->labelOptions['label'] .= ' <span class="glyphicon glyphicon-question-sign" style="font-size: 8pt;" aria-hidden="true"></span>';
$this->labelOptions['label'] .= '</span>';
} else {
$this->labelOptions['label'] = Html::encode($this->model->getAttributeLabel($this->attribute));
}
$this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
}
if (!isset($this->parts['{error}'])) {
$this->parts['{error}'] = Html::error($this->model, $this->attribute, $this->errorOptions);
}
if (!isset($this->parts['{hint}'])) {
$this->parts['{hint}'] = '';
}
$content = strtr($this->template, $this->parts);
} elseif (!is_string($content)) {
$content = call_user_func($content, $this);
}
return $this->begin() . "\n" . $content . "\n" . $this->end();
}
示例8: 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>
';
}
示例9: 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);
}
示例10: run
/**
* Renders the widget.
*/
public function run()
{
$contents = [];
if ($this->inline) {
if ($this->hasModel()) {
$contents[] = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
} else {
$contents[] = Html::hiddenInput($this->name, $this->value, $this->options);
}
$contents[] = Html::tag('div', '', $this->containerOptions);
} else {
if ($this->hasModel()) {
$contents[] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$contents[] = Html::textInput($this->name, $this->value, $this->options);
}
}
echo implode("\n", $contents);
if ($this->language) {
DatePickerAsset::$extraJs[] = 'plugins/bootstrap-datepicker-extended/js/locales/bootstrap-datepicker.' . $this->language . '.js';
$this->clientOptions['language'] = $this->language;
}
DatePickerAsset::register($this->view);
$this->registerPlugin('datepicker');
if ($this->inline) {
$this->view->registerJs("\n !(function(\$){\n var el = \$('#{$this->options['id']}'),\n val = el.val(),\n container = \$('#{$this->containerOptions['id']}');\n container.on('changeDate', function(e){\n el.val(e.format());\n });\n if(val) {\n container.datepicker('update', new Date(Date.parse(val)));\n }\n })(jQuery);\n ", View::POS_READY);
}
}
示例11: textInput
/**
* @inheritdoc
*/
public function textInput($options = [])
{
$options = array_merge($this->inputOptions, $options);
$this->adjustLabelFor($options);
$this->parts['{input}'] = Html::activeTextInput($this->model, $this->attribute, $options);
return $this;
}
示例12: renderRow
/**
*
* @param biz\models\GlDetail $model
* @param integer $index
* @return string
*/
function renderRow($model, $index)
{
ob_start();
ob_implicit_flush(false);
?>
<tr>
<?php
echo Html::activeHiddenInput($model, "[{$index}]id_gl_detail");
?>
<td class="serial"><?php
echo $index;
?>
</td>
<td><?php
echo Html::activeTextInput($model, "[{$index}]id_coa");
?>
</td>
<td><?php
echo Html::activeTextInput($model, "[{$index}]debit");
?>
</td>
<td><?php
echo Html::activeTextInput($model, "[{$index}]kredit");
?>
</td>
<td class="action"><a class="fa fa-minus-square-o" href="#"></a></td>
</tr>
<?php
return trim(preg_replace('/>\\s+</', '><', ob_get_clean()));
}
示例13: 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);
}
示例14: 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;
}
示例15: 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) . ");});");
}
}