當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。