コード例 #1
2
 /**
  *
  */
 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
1
 /**
  * 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
1
ファイル: _search.php プロジェクト: kocapb/library
?>

<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
0
ファイル: ActiveField.php プロジェクト: bmsrox/yiicomm
 /**
  * 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
0
ファイル: _filter.php プロジェクト: ninetor/yii-classifield
    <?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
0
ファイル: _filter.php プロジェクト: worstinme/yii2-zoo
});
$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
0
<?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
0
ファイル: FieldCategory.php プロジェクト: letyii/cms
 /**
  * Renders the widget.
  */
 public function run()
 {
     $categories = LetCategory::getCategory($this->model->moduleName(), '-- ');
     echo Html::activeCheckboxList($this->model, $this->attribute, $categories, $this->options);
 }
コード例 #9
0
<?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
-1
 /**
  * @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
-2
ファイル: CheckBoxControl.php プロジェクト: phpdn/qc-base
 /**
  * @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);
 }