本文整理汇总了PHP中yii\bootstrap\Html::label方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::label方法的具体用法?PHP Html::label怎么用?PHP Html::label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\bootstrap\Html
的用法示例。
在下文中一共展示了Html::label方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
Pjax::begin(['enablePushState' => false, 'id' => 'begin-graduate']);
echo Html::tag('h4', 'Выберите интересующую вас тему из списка уже существующих, либо предложите свою.');
$form = ActiveForm::begin(['id' => 'begin-graduate-form', 'options' => ['class' => 'form-horizontal', 'data-pjax' => true]]);
?>
<div class="form-group">
<?php
echo Html::label('Список тем');
?>
<?php
echo Html::listBox('workList', null, $workListArr, ['class' => 'form-control', 'options' => $disabledWorks]);
?>
</div>
<div class="form-group">
<?php
echo Html::label('Новая тема');
?>
<div class="input-group ">
<span class="input-group-addon">
<?php
echo Html::checkbox('newWorkCheckbox');
?>
</span>
<span class="input-group-addon" id="basic-addon1">
Название
</span>
<?php
echo Html::textInput('newWorkName', null, ['class' => 'form-control']);
?>
<span class="input-group-addon" id="basic-addon1">
Руководитель
示例2: getItem
/**
* @param null $options
* @param null $pluginOptions
*
* @return string
* @throws \Exception
*/
public function getItem($options = null, $pluginOptions = null)
{
switch ($this->type) {
case self::TYPE_TEXT:
return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_EMAIL:
return Html::input('email', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_NUMBER:
return Html::input('number', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_TEXTAREA:
return Html::textarea('Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
case self::TYPE_COLOR:
return ColorInput::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'options' => $options != null ? $options : ['class' => 'form-control']]);
case self::TYPE_DATE:
return DatePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['format' => 'yyyy-mm-dd', 'todayHighlight' => true]]);
case self::TYPE_TIME:
return TimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['minuteStep' => 1, 'showSeconds' => true, 'showMeridian' => false]]);
case self::TYPE_DATETIME:
return DateTimePicker::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['format' => 'yyyy-mm-dd H:i:s', 'todayHighlight' => true]]);
case self::TYPE_PASSWORD:
return PasswordInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['showMeter' => true, 'toggleMask' => false]]);
case self::TYPE_ROXYMCE:
return RoxyMceWidget::widget(['id' => 'Setting_' . $this->code, 'name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'action' => Url::to(['roxymce/default']), 'options' => $options != null ? $options : ['title' => $this->getName()], 'clientOptions' => $pluginOptions != null ? $pluginOptions : []]);
case self::TYPE_SELECT:
return Select2::widget(['value' => $this->value, 'name' => 'Setting[' . $this->code . ']', 'data' => $this->getStoreRange(), 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => ['allowClear' => true]]);
case self::TYPE_MULTI_SELECT:
$options['multiple'] = true;
if (!isset($options['class'])) {
$options['class'] = 'form-control';
}
return Select2::widget(['name' => 'Setting[' . $this->code . ']', 'value' => explode(",", $this->value), 'data' => $this->getStoreRange(), 'options' => $options, 'pluginOptions' => ['allowClear' => true]]);
case self::TYPE_FILE_PATH:
$value = Yii::getAlias($this->store_dir) . DIRECTORY_SEPARATOR . $this->value;
return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control', 'multiple' => false], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreview' => !$this->isNewRecord ? [$this->value] : []]]);
case self::TYPE_FILE_URL:
$value = $this->store_url . '/' . $this->value;
return FileInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $value, 'options' => $options != null ? $options : ['class' => 'form-control'], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['previewFileType' => 'any', 'showRemove' => false, 'showUpload' => false, 'initialPreviewAsData' => true, 'initialPreviewFileType' => self::fileType(pathinfo($this->value, PATHINFO_EXTENSION)), 'initialPreview' => !$this->isNewRecord ? $value : [], 'initialCaption' => $this->value]]);
case self::TYPE_PERCENT:
return RangeInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $this->value, 'html5Options' => ['min' => 0, 'max' => 100, 'step' => 1], 'options' => $options != null ? $options : ['class' => 'form-control'], 'addon' => ['append' => ['content' => '%']]]);
case self::TYPE_SWITCH:
$selector = explode(',', $this->store_range);
if (count($selector) != 2) {
throw new ErrorException(Yii::t('setting', 'Switch Field should have store with 2 value, and negative is first. Example: no,yes'), 500);
}
return Html::hiddenInput('Setting[' . $this->code . ']', $selector[0]) . SwitchInput::widget(['name' => 'Setting[' . $this->code . ']', 'value' => $selector[1], 'containerOptions' => ['class' => 'nv-switch-container'], 'options' => $options != null ? $options : [], 'pluginOptions' => $pluginOptions != null ? $pluginOptions : ['state' => $this->value == $selector[1], 'size' => 'small', 'offText' => ucfirst($selector[0]), 'onText' => ucfirst($selector[1])]]);
case self::TYPE_CHECKBOX:
$random = rand(1000, 9999);
return Html::checkboxList('Setting[' . $this->code . ']', explode(",", $this->value), $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list checkbox', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
$html = Html::beginTag('div');
$html .= Html::checkbox($name, $checked, ['id' => 'Setting_checkbox_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
$html .= Html::label($label, 'Setting_checkbox_' . $label . '_' . $index . '_' . $random);
$html .= Html::endTag('div');
return $html;
}]);
case self::TYPE_RADIO:
$random = rand(1000, 9999);
return Html::radioList('Setting[' . $this->code . ']', $this->value, $this->getStoreRange(), $options != null ? $options : ['class' => 'nv-checkbox-list radio', 'item' => function ($index, $label, $name, $checked, $value) use($random) {
$html = Html::beginTag('div');
$html .= Html::radio($name, $checked, ['id' => 'Setting_radio_' . $label . '_' . $index . '_' . $random, 'value' => $value]);
$html .= Html::label($label, 'Setting_radio_' . $label . '_' . $index . '_' . $random);
$html .= Html::endTag('div');
return $html;
}]);
case self::TYPE_SEPARATOR:
return '<hr>';
default:
return Html::input('text', 'Setting[' . $this->code . ']', $this->value, $options != null ? $options : ['placeholder' => $this->getName(), 'class' => 'form-control']);
}
}
示例3:
<?php
/**
* @var string $id
* @var string $name
* @var double $value
* @var boolean $readonly
*/
?>
<div class="star-rating">
<div class="star-rating__wrap">
<?php
$a = 1;
for ($i = 5; $i > 0; $i--) {
$inputOptions = ['class' => 'star-rating__input', 'id' => "{$id}-star-rating-{$i}", 'name' => $name];
if ($i == round($value)) {
$inputOptions['checked'] = 'checked';
}
if ($readonly) {
$inputOptions['disabled'] = 'disabled';
}
echo \yii\helpers\Html::input('radio', $name, $i, $inputOptions);
echo \yii\bootstrap\Html::label('', "{$id}-star-rating-{$i}", ['class' => 'star-rating__ico fa fa-star-o fa-lg' . ($readonly ? false : ' editable'), 'title' => Yii::t('app', '{0} out of {1} stars', [$i, 5])]);
}
?>
</div>
</div>
示例4:
echo Html::label('Старые варианты');
?>
<div class="input-group ">
<span class="input-group-addon">
<?php
echo Html::radio('source', false, ['value' => 'history']);
?>
</span>
<?php
echo Html::dropDownList('oldWorkName', null, $oldList, ['class' => 'form-control']);
?>
</div>
</div>
<div class="form-group">
<?php
echo Html::label('Выбрать из списка преподавателя');
?>
<div class="input-group ">
<span class="input-group-addon">
<?php
echo Html::radio('source', false, ['value' => 'list']);
?>
</span>
<?php
echo Html::dropDownList('listWorkName', null, $workList, ['class' => 'form-control']);
?>
</div>
</div>
<div class="form-group">
<div class="col-lg-12">
<?php
示例5: labelInput
private static function labelInput($fieldName, $fld, $input)
{
$html = '';
$html .= Html::beginTag('div', ['class' => 'form-group']);
$html .= Html::label(Inflector::camel2words($fieldName), $fld, ['class' => 'col-lg-2 control-label']);
$html .= Html::beginTag('div', ['class' => 'col-lg-10']);
$html .= $input;
$html .= Html::endTag('div');
$html .= Html::endTag('div');
return $html;
}
示例6: function
<?php
use common\widgets\Grid;
use yii\bootstrap\Html;
$this->title = 'Users';
?>
<?php
echo Grid::widget(['caption' => 'Hello world!', 'dataProvider' => $dataProvider, 'columns' => ['id', 'email', 'created:datetime', 'updated:datetime', ['label' => 'Status', 'format' => 'raw', 'value' => function ($row) use($model) {
$status = $model::getStatuses($row->status);
return Html::label($status['label'], null, ['class' => 'label label-' . $status['type']]);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
<div class="page__content">
<div class="page__content-title">Title</div>
<div class="page__content-inner">Hello from content</div>
</div>
示例7:
</div>
<div class="col-lg-6">
<h2 class="text-center">В</h2>
<div class="form-group">
<?php
echo Html::label('Платежная система', 'from_billing');
?>
<?php
echo Html::dropDownList('to_billing', null, $billings, ['id' => 'to_billing', 'class' => 'form-control', 'prompt' => 'Выберите платежную систему...']);
?>
</div>
<div class="form-group">
<?php
echo Html::label('Валюта', 'to_billing');
?>
<?php
echo DepDrop::widget(['name' => 'to_currency', 'options' => ['id' => 'to_currency', 'placeholder' => 'Выберите валюту...'], 'pluginEvents' => ['change' => 'getRate'], 'pluginOptions' => ['depends' => ['to_billing'], 'placeholder' => 'Выберите валюту...', 'url' => Url::to(['/site/currency']), 'loadingText' => 'Загрузка ...']]);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h2 class="text-center">Результат:</h2>
<p id="result"></p>
</div>
</div>