本文整理汇总了PHP中yii\helpers\Html::activeCheckboxList方法的典型用法代码示例。如果您正苦于以下问题:PHP Html::activeCheckboxList方法的具体用法?PHP Html::activeCheckboxList怎么用?PHP Html::activeCheckboxList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\helpers\Html
的用法示例。
在下文中一共展示了Html::activeCheckboxList方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
*
*/
public function run()
{
$view = $this->getView();
$this->registerScript($view);
if ($this->hasModel()) {
$list = Html::activeCheckboxList($this->model, $this->attribute, $this->items, $this->options);
} else {
$list = Html::checkboxList($this->name, $this->value, $this->items, $this->options);
}
$input = Html::tag('div', $list, $this->containerOptions);
echo strtr($this->template, ['{input}' => $input]);
}
示例2: renderInput
/**
* render the html input for the widget
*/
protected function renderInput()
{
if ($this->hasModel()) {
$content = Html::activeCheckboxList($this->model, $this->attribute, $this->items, $this->options);
} else {
$content = Html::checkboxList($this->name, $this->value, $this->items, $this->options);
}
return Html::tag('div', $content, ['id' => $this->widgetId . '-checkbox', 'class' => 'checkbox_button_group' . '_checkbox']);
}
示例3: function
?>
<div class="user-search">
<?php
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>
<?php
echo $form->field($model, 'username');
?>
<?php
echo Html::activeCheckboxList($model, 'cities', $cities, ['item' => function ($index, $label, $name, $checked, $value) use($model) {
$selected_ids = Yii::$app->session['UserSearch']['cities'];
$checked = $selected_ids ? in_array($value, $selected_ids) : false;
return Html::checkbox($name, $checked, ['value' => $value, 'label' => Html::encode($label)]);
}]);
?>
<?php
echo $form->field($model, 'education_id')->dropDownList($educations, ['prompt' => 'Select education']);
?>
<div class="form-group">
<?php
echo Html::submitButton('Search', ['class' => 'btn btn-primary']);
?>
<?php
示例4: checkboxList
/**
* Renders a list of checkboxes.
* A checkbox list allows multiple selection, like [[listBox()]].
* As a result, the corresponding submitted value is an array.
* The selection of the checkbox list is taken from the value of the model attribute.
* @param array $items the data item used to generate the checkboxes.
* The array values are the labels, while the array keys are the corresponding checkbox values.
* Note that the labels will NOT be HTML-encoded, while the values will.
* @param array $options options (name => config) for the checkbox list. The following options are specially handled:
*
* - unselect: string, the value that should be submitted when none of the checkboxes is selected.
* By setting this option, a hidden input will be generated.
* - separator: string, the HTML code that separates items.
* - item: callable, a callback that can be used to customize the generation of the HTML code
* corresponding to a single item in $items. The signature of this callback must be:
*
* ~~~
* function ($index, $label, $name, $checked, $value)
* ~~~
*
* where $index is the zero-based index of the checkbox in the whole list; $label
* is the label for the checkbox; and $name, $value and $checked represent the name,
* value and the checked status of the checkbox input.
* @return static the field object itself
*/
public function checkboxList($items, $options = [])
{
$this->adjustLabelFor($options);
$this->parts['{input}'] = Html::activeCheckboxList($this->model, $this->attribute, $items, $options);
return $this;
}
示例5: function
<?php
$form = ActiveForm::begin(['method' => 'get', 'enableClientScript' => false, 'action' => Url::current()]);
?>
<div class="filter-box">
<!-- <div class="filter-check">-->
<!-- <label class="checkbox-style"><input type="checkbox"><i></i> Free delivery</label>-->
<!-- </div>-->
<div class="box-toggle">
<div class="toggle-header">Brands</div>
<div class="toggle-in">
<div class="scroll-pane">
<ul class="filter-checkbox">
<?php
echo Html::activeCheckboxList($searchModel, 'brand_id', $brands, ['item' => function ($index, $label, $name, $checked, $value) use($brandsProductCount) {
return '<li><label class="checkbox-style">' . Html::checkbox($name, $checked, ['value' => $value]) . '<i></i> ' . $label . ' <span>(' . $brandsProductCount[$value] . ')</span></label></li>';
}]);
?>
</ul>
</div>
</div>
</div>
<?php
echo Filter::widget(['propertiesProvider' => $this->params['propertiesProvider']]);
?>
<?php
echo \yii\helpers\Html::submitButton('Apply filter', ['class' => 'filter-btn']);
?>
</div>
示例6: foreach
});
$values = $searchModel->{$element->name};
if (is_array($values) && count($values)) {
foreach ($values as $value) {
if ($value !== null && !empty($value)) {
$variants[$value] = $value;
}
}
}
if (count($variants)) {
?>
<label class="f-label"><?php
echo $element->title;
?>
</label>
<?php
echo Html::activeCheckboxList($searchModel, $element->name, $variants, ['class' => $element->name . '-filter checkbox-filter']);
?>
<?php
if (count($variants) > 5) {
?>
<?php
echo Html::a('Показать все', '#', ['class' => 'dfn', 'data-uk-toggle' => "{cls: 'active', target:'#" . Html::getInputId($searchModel, $element->name) . "'}"]);
}
?>
<?php
}
示例7: function
<?php
echo \yii\helpers\Html::activeCheckboxList($model, $attribute, $items, ['class' => 'btn-group', 'data-toggle' => 'buttons', 'item' => function ($index, $label, $name, $checked, $value) {
return \yii\helpers\Html::checkbox($name, $checked, ['value' => $value, 'label' => $label, 'container' => false, 'labelOptions' => ['class' => "btn btn-{$this->context->type} btn-{$this->context->size}" . ($checked ? ' active' : '')]]);
}]);
示例8: run
/**
* Renders the widget.
*/
public function run()
{
$categories = LetCategory::getCategory($this->model->moduleName(), '-- ');
echo Html::activeCheckboxList($this->model, $this->attribute, $categories, $this->options);
}
示例9:
<?php
echo \yii\helpers\Html::activeCheckboxList($role, 'users', $users, ['onchange' => '$.get("/rbac/auth-assignment/change", {
"id" : "' . $role->name . '",
"user_id" : event.target.value,
"add" : $(event.target).is(":checked") ? 1 : 0
}).error(function(data){alert(data.responseText);});']);
示例10: renderInput
/**
* @return string
*/
public function renderInput()
{
return $this->hasModel() ? Html::activeCheckboxList($this->model, $this->attribute, $this->items, $this->options) : Html::checkboxList($this->name, $this->selection, $this->items, $this->options);
}
示例11: renderHtml
/**
* @inheritdoc
*/
public function renderHtml()
{
if ($this->form !== null && $this->model !== null) {
return $this->form->field($this->model, $this->attribute)->hint($this->hint)->checkboxList($this->items, $this->options);
}
if ($this->model !== null) {
return Html::activeCheckboxList($this->model, $this->attribute, $this->items, $this->options);
}
return Html::checkboxList($this->name, $this->value, $this->items, $this->options);
}