本文整理汇总了PHP中yii\helpers\Html::activeLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::activeLabel方法的具体用法?PHP Html::activeLabel怎么用?PHP Html::activeLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::activeLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$label = Html::activeLabel($this->translations[0], $this->fieldName, ['class' => 'control-label']);
$tabs = Tabs::widget(['encodeLabels' => false, 'items' => $this->_tabItems, 'options' => ['class' => 'translation-tabs']]);
$content = Html::tag('div', $label . $tabs, ['class' => 'form-group nav-tabs-custom language-tabs']);
return $content;
}
示例2: run
public function run()
{
echo Html::activeLabel($this->model, $this->titleAttribute);
echo Html::activeTextInput($this->model, $this->titleAttribute, ['id' => 'title-input', 'maxlength' => 64]);
echo '<div id="slug-block">';
echo Html::activeLabel($this->model, $this->slugAttribute);
echo Html::activeTextInput($this->model, $this->slugAttribute, ['id' => 'slug-input', 'value' => '', 'maxlength' => 64]);
echo '
<div id="results"></div>
</div><!--/slug-block-->
';
$this->registerAssets();
}
示例3: 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>
';
}
示例4: renderHtml
/**
* @inheritdoc
*/
public function renderHtml()
{
if ($this->model !== null) {
return Html::activeLabel($this->model, $this->attribute, $this->options);
}
return Html::label($this->text, null, $this->options);
}
示例5: 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();
}
示例6: renderLabel
public function renderLabel()
{
if (!isset($this->labelOptions['for'])) {
$this->labelOptions['for'] = $this->inputOptions['id'];
}
return $this->hasModel() ? Html::activeLabel($this->model, $this->attribute, $this->labelOptions) : Html::label($this->label, $this->labelOptions['for'], $this->labelOptions);
}
示例7: init
public function init()
{
parent::init();
$this->_inputStr = '<div class="form-group">';
$this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
$this->_inputStr .= Html::activeDropDownList($this->model, $this->attribute, \common\models\User::getUserGroup(), $this->options);
$this->_inputStr .= '</div>';
}
示例8: renderInput
/**
* Renders the input
*
* @return string
*/
protected function renderInput()
{
$this->options = array_merge($this->options, ['style' => $this->inputStyle]);
if (!$this->hideInput) {
return Html::activeLabel($this->model, $this->attribute, ['class' => 'control-label']) . '<div class="input-group drp-container form-drp-input" style="' . $this->wrapperStyle . '">' . $this->getInput('textInput') . Html::submitButton('<span class="glyphicon glyphicon-floppy-save"></span> ' . \Yii::t('admin', 'Export'), ['class' => 'btn btn-info']) . '</div>' . '<div class="help-block ">' . Html::error($this->model, $this->attribute, ['class' => 'help-block help-block-error']) . '</div>';
}
$tag = ArrayHelper::remove($this->containerOptions, 'tag', 'div');
$content = str_replace('{input}', $this->getInput('hiddenInput'), $this->containerTemplate);
$content = str_replace('{error}', '<div class="help-block ">' . Html::error($this->model, $this->attribute, ['class' => 'help-block help-block-error']) . '</div>', $content);
return Html::tag($tag, $content, $this->containerOptions);
}
示例9: checkbox
public function checkbox($options = [], $type = 'checkbox', $enclosedByLabel = true)
{
if ($type == 'checkbox') {
$classname = '\\vx\\Semantic\\Modules\\Checkbox';
} else {
$classname = '\\vx\\Semantic\\Modules\\Radio';
}
$config = $this->getCheckboxListOptions($options);
$checkboxOptions = $config['checkbox'];
$options = ['options'];
$this->parts['{label}'] = '';
$this->parts['{input}'] = $classname::widget(['class' => $classname::className(), 'model' => $this->model, 'attribute' => $this->attribute, 'options' => $options, 'label' => Html::activeLabel($this->model, $this->attribute, $this->labelOptions), 'inputOptions' => $checkboxOptions['inputOptions'], 'labelOptions' => $checkboxOptions['labelOptions'], 'type' => $checkboxOptions['type'], 'readOnly' => $checkboxOptions['readOnly'], 'disabled' => $checkboxOptions['disabled'], 'fitted' => $checkboxOptions['fitted'], 'encodeLabel' => $checkboxOptions['encodeLabel']]);
return $this;
}
示例10: run
public function run()
{
$model = $this->model;
$attribute = $this->attribute;
$path = $model->{$attribute} ?: $this->path . "/images/noimage.gif";
$this->_html .= '<div class="form-group field-article-author" id="container">';
$this->_html .= Html::activeLabel($model, $attribute);
$this->_html .= Html::activeHiddenInput($model, $attribute, ['id' => 'hidden_input', 'value' => $path]);
$this->_html .= '<div id="pickfiles" style="height:50px;min-width:50px;max-width: 300px;overflow: hidden;"><img height="50" src="' . $path . '" /></div>';
$this->_html .= '</div> ';
UploadAsset::register($this->view);
$this->view->registerJs('$(function(){
initCoverImageUploader("pickfiles","container","2mb","' . $this->url . '","' . Yii::$app->request->getCsrfToken() . '","' . $this->path . '");
});');
return $this->_html;
}
示例11: imageField
/**
* Generates a form field.
* A form field is associated with a model and an attribute. It contains a label, an input and an error message
* and use them to interact with end users to collect their inputs for the attribute.
* @param Model $model the data model
* @param string $attribute the attribute name or expression. See [[Html::getAttributeName()]] for the format
* about attribute expression.
* @param array $options the additional configurations for the field object. These are properties of [[ActiveField]]
* or a subclass, depending on the value of [[fieldClass]].
* @return string the created ActiveField object
* @see fieldConfig
*/
public function imageField($model, $attribute, $options = [])
{
if ($model->{$attribute}) {
$src = '@web/' . $model->{$attribute};
} else {
$src = '@web/images/no_image.jpg';
}
$imageField = '';
$imageField .= Html::activeLabel($model, $attribute, ['class' => 'col-sm-12 control-label']);
$imageField .= Html::beginTag('label', ['for' => Html::getInputId($model, $attribute), ['class' => 'col-sm-8']]);
$imageField .= Html::img($src, $options);
$imageField .= Html::endTag('label');
$imageField .= Html::beginTag('span', ['class' => 'image-trash glyphicon glyphicon-remove-circle']);
$imageField .= Html::endTag('span');
$imageField .= Html::activeFileInput($model, $attribute, ['style' => 'display:none']);
$imageField .= Html::activeHiddenInput($model, 'removeImage', ['value' => '0']);
return $imageField;
}
示例12: render
/**
* @inheritdoc
*/
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}'])) {
$this->parts['{label}'] = Html::activeLabel($this->model, $this->attribute, $this->labelOptions);
}
if (!isset($this->parts['{error}'])) {
$this->parts['{error}'] = $this->_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();
}
示例13: renderField
protected function renderField($fieldName)
{
$type = $this->checkCustomType($fieldName);
if (!$type) {
$type = $this->schema->columns[$fieldName]->type;
}
$field = $this->form->field($this->owner, $fieldName);
switch ($type) {
case self::TypeHidden:
$input = $field->hiddenInput();
break;
case self::TypePassword:
$input = $field->passwordInput();
break;
case self::TypeFile:
$input = $field->fileInput();
break;
case self::TypeBoolean:
$input = $field->checkbox();
break;
case self::TypeDropDown:
$input = $field->dropDownList($this->config['dropDown'][$fieldName]);
break;
case self::TypeText:
$input = $field->textarea();
break;
default:
$input = $field->textInput();
}
if (array_key_exists($fieldName, $this->widget)) {
$input->widget($this->widget[$fieldName]['class'], $this->widget[$fieldName]['config']);
}
if ($type != self::TypeHidden) {
$label = $type == self::TypeBoolean ? '' : Html::activeLabel($this->owner, $fieldName);
$error = implode(', ', $this->owner->getErrors($fieldName));
return "<div class='field {$type}'>\n {$label}\n {$input->parts['{input}']}\n {$error}\n </div>";
} else {
return $input->parts['{input}'];
}
}
示例14: init
public function init()
{
parent::init();
$this->options['encodeSpaces'] = true;
$this->options['prompt'] = '不选择';
$categories = CategoryTree::getInstance()->getAllCategories();
if (!empty($categories)) {
foreach ($categories as $v) {
$tempArr = [];
$tempArr[$v['mid']] = str_repeat(' ', $v['depth'] - 1) . $v['name'];
$this->_categories += $tempArr;
if ($this->currentOptionDisabled) {
$model = $this->model;
$this->options['options'][$model->mid] = ['disabled' => true];
}
}
}
$this->_inputStr = '<div class="form-group">';
$this->_inputStr .= Html::activeLabel($this->model, $this->attribute);
$this->_inputStr .= Html::activeDropDownList($this->model, $this->attribute, $this->_categories, $this->options);
$this->_inputStr .= '</div>';
}
示例15: init
public function init()
{
parent::init();
$this->options['encodeSpaces'] = true;
$this->options['prompt'] = '不选择';
$categories = Category::getChildCategories(intval($this->parent));
if (!empty($categories)) {
foreach ($categories as $v) {
$tempArr = [];
$tempArr[$v['id']] = str_repeat(' ', $v['class'] - 1) . $v['name'];
$this->_categories += $tempArr;
if ($this->currentOptionDisabled) {
$model = $this->model;
$this->options['options'][$model->id] = ['disabled' => 'disabled'];
}
}
}
$this->_html = '<div class="form-group">';
$this->_html .= Html::activeLabel($this->model, $this->attribute);
$this->_html .= Html::activeDropDownList($this->model, $this->attribute, $this->_categories, $this->options);
$this->_html .= '</div>';
}