当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::getToSelect方法代码示例

本文整理汇总了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">&times;</button>
                <h4 class="modal-title" id="myModalLabel"><?php 
echo Yii::t('backend', 'Дерево категорий товаров');
?>
</h4>
            </div>
开发者ID:dmdropkick,项目名称:shop,代码行数:31,代码来源:index.php

示例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();
开发者ID:dmdropkick,项目名称:shop,代码行数:31,代码来源:_form.php


注:本文中的common\models\Category::getToSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。