本文整理汇总了PHP中common\models\Category::getToSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getToSelect方法的具体用法?PHP Category::getToSelect怎么用?PHP Category::getToSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\Category
的用法示例。
在下文中一共展示了Category::getToSelect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
echo Yii::t('backend', 'Дерево категорий');
?>
</button>
</p>
<?php
Pjax::begin(['enablePushState' => false]);
?>
<?php
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'layout' => "{items}\n{summary}\n{pager}", 'options' => ['class' => 'grid-view table-responsive'], 'tableOptions' => ['class' => 'table table-striped table-bordered table-hover'], 'rowOptions' => function ($model, $key, $index, $grid) {
// Если категория неактивна.
if (!$model->status) {
return ['class' => 'danger'];
}
}, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id:integer', 'slug:text', ['attribute' => 'tree', 'filter' => Category::getToSelect(), 'value' => function ($model) {
return $model->id == $model->tree ? Yii::t('backend', 'Главная категория') : Category::getToSelect()[$model->tree];
}], 'name:text', 'description:text', ['attribute' => 'status', 'filter' => [0 => Yii::t('backend', 'Нет'), 1 => Yii::t('backend', 'Да')], 'format' => 'boolean', 'contentOptions' => ['class' => 'table__center']], ['class' => 'yii\\grid\\ActionColumn']]]);
Pjax::end();
?>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel"><?php
echo Yii::t('backend', 'Дерево категорий товаров');
?>
</h4>
</div>
示例2: unset
/* @var $this yii\web\View */
/* @var $model common\models\Category */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="category-form">
<?php
$form = ActiveForm::begin(['validateOnType' => true, 'layout' => 'horizontal', 'options' => ['enctype' => 'multipart/form-data'], 'fieldConfig' => ['options' => ['class' => 'form-group']]]);
?>
<div class="form-group">
<label class="control-label col-sm-3" for="parent_category_id"><?php
echo Yii::t('backend', 'Родительская категория');
?>
</label>
<div class="col-sm-6"><?php
$categories = Category::getToSelect();
if (!$model->isNewRecord) {
unset($categories[$model->id]);
}
?>
<?php
echo Html::dropDownList('parent_category_id', isset($model->tree) && $model->tree != $model->id ? $model->tree : null, $categories, ['id' => 'parent_category_id', 'class' => 'form-control', 'prompt' => Yii::t('backend', 'Нет')]);
?>
</div>
</div>
<?php
echo $form->field($model, 'slug')->textInput();
?>
<?php
echo $form->field($model, 'name')->textInput();