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


PHP Category::getAllToList方法代码示例

本文整理汇总了PHP中common\models\Category::getAllToList方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::getAllToList方法的具体用法?PHP Category::getAllToList怎么用?PHP Category::getAllToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\Category的用法示例。


在下文中一共展示了Category::getAllToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

<?php 
\yii\widgets\Pjax::begin();
?>
<div class="box">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $filterModel, 'layout' => "<div class='box-body table-responsive no-padding'>{items}</div><div class='box-footer'><div class='row'><div class='col-sm-6'>{summary}</div><div class='col-sm-6 text-right'>{pager}</div></div></div>", 'tableOptions' => ['class' => 'table table-hover'], 'columns' => [['attribute' => 'id', 'options' => ['width' => '50'], 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'value' => function ($data) {
    return $data->id;
}], ['class' => CheckboxColumn::className(), 'options' => ['width' => '50'], 'headerOptions' => ['class' => 'checkbox-column text-center'], 'contentOptions' => ['class' => 'checkbox-column text-center']], ['attribute' => 'title', 'filterInputOptions' => ['class' => 'form-control input-sm'], 'format' => 'raw', 'value' => function ($data) {
    return Html::a($data->title, Url::toRoute(['/catalog/update-product', 'id' => $data->id]), ['data-pjax' => 0]);
}], ['header' => 'Категории', 'format' => 'raw', 'value' => function ($data) {
    $tmp = '';
    foreach ($data->categories as $cItem) {
        $tmp .= '<div>' . Html::a($cItem->title, Url::toRoute(['/catalog/products', 'Product[parents]' => $cItem->id])) . '</div>';
    }
    return $tmp;
}, 'filter' => Html::activeDropDownList($filterModel, 'parents', Category::getAllToList(), ['class' => 'form-control input-sm filtered', 'prompt' => '-'])], ['attribute' => 'price', 'format' => 'raw', 'value' => function ($data) {
    return Yii::$app->formatter->asCurrency($data->price, 'RUR');
}], ['attribute' => 'quantity', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'format' => 'raw', 'value' => function ($data) {
    return Yii::$app->formatter->asInteger($data->quantity);
}], ['attribute' => 'is_active', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'format' => 'html', 'value' => function ($data) {
    return $data->is_active ? '<span class="label label-success">Активный</span>' : '<span class="label label-danger">Не активный</span>';
}, 'filter' => Html::activeDropDownList($filterModel, 'is_active', [true => 'Активный', false => 'Не активный'], ['class' => 'form-control input-sm filtered', 'prompt' => '-'])], ['attribute' => 'created_at', 'format' => 'raw', 'options' => ['width' => '200'], 'value' => function ($data) {
    return Yii::$app->formatter->asDateTime($data->created_at, Yii::$app->formatter->dateFormat) . ' <small style="color:gray;">' . Yii::$app->formatter->asDateTime($data->created_at, Yii::$app->formatter->timeFormat) . '</small>';
}, 'filter' => DateTimePicker::widget(['name' => 'Product[created_at]', 'value' => $filterModel->created_at != '' ? Yii::$app->formatter->asDateTime($filterModel->created_at, Yii::$app->formatter->dateFormat) : null, 'options' => ['placeholder' => 'Введите дату ...', 'class' => 'form-control input-sm filtered'], 'size' => 'sm', 'pickerButton' => null, 'convertFormat' => true, 'type' => DateTimePicker::TYPE_COMPONENT_APPEND, 'pluginOptions' => ['format' => 'dd.MM.yyyy', 'autoclose' => true, 'todayBtn' => true, 'startView' => 2, 'minView' => 3]])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update-product} {delete-product}', 'options' => ['width' => '100'], 'buttons' => ['update-product' => function ($url, $model) {
    return Html::a('<span class="icon fa fa-edit"></span>', $url, ['class' => 'btn btn-xs btn-primary', 'data-pjax' => 0]);
}, 'delete-product' => function ($url, $model) {
    return Html::a('<span class="icon fa fa-trash"></span>', $url, ['class' => 'btn btn-xs btn-danger isDel', 'data-pjax' => 0]);
}]]]]);
?>
</div>
开发者ID:andreykluev,项目名称:yii2-catalog-module,代码行数:30,代码来源:products.php

示例2:

<?php 
$form = ActiveForm::begin(['id' => 'form-category-update', 'options' => ['enctype' => 'multipart/form-data']]);
?>
<div class="box">
    <div class="box-body">
        <div class="row">
            <div class="col-xs-6">
                <?php 
echo $form->field($model, 'title');
?>
            </div>

            <div class="col-xs-6">
                <?php 
echo $form->field($model, 'parent')->widget(Chosen::className(), ['placeholder' => 'Выберите родителя', 'items' => Category::getAllToList(), 'multiple' => false]);
?>
            </div>
        </div>

        <?php 
echo $form->field($model, 'description')->widget(imperaviWidget::className());
?>
    </div>
    <div class="box-footer text-right">
        <?php 
echo Html::submitButton('Сохранить', ['class' => 'btn btn-primary', 'name' => 'save-button']);
?>
    </div>
</div>
<?php 
开发者ID:andreykluev,项目名称:yii2-catalog-module,代码行数:30,代码来源:update-cat.php


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