本文整理匯總了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();