Exemplo n.º 1
0
<?php

\Yii::$container->set(\yii\widgets\Pjax::className(), ["timeout" => false]);
\Yii::$container->set(\mcms\xeditable\XEditableAsset::className(), ["publishOptions" => ['forceCopy' => false]]);
\Yii::$container->set(\yii\jui\DatePicker::className(), ['language' => "ru", "dateFormat" => "yyyy-MM-dd"]);
\Yii::$container->set(\mcms\xeditable\XEditableColumn::className(), ['editable' => null]);
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function xEditable()
 {
     return ['class' => \mcms\xeditable\XEditableColumn::className(), 'url' => $this->getEditableUrl(), 'dataType' => 'select', 'format' => 'raw', 'editable' => ['source' => $this->defaultGridFilter()]];
 }
Exemplo n.º 3
0
    <p>
        <?php 
echo Html::a('Create An Items', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-hover'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['attribute' => 'text', 'format' => 'raw', 'value' => function ($searchModel) {
    return '<div class="grid-text">' . $searchModel->text . '</div>';
}], ['label' => 'category', 'attribute' => 'category', 'value' => 'cat.name'], ['label' => 'region', 'attribute' => 'region', 'value' => 'region.name'], ['attribute' => 'created_at', 'format' => 'date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'created_at', 'dateFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'form-control']])], ['attribute' => 'status', 'value' => function ($searchModel) {
    $class = $searchModel->status === $searchModel::STATUS_PUBLISHED ? 'label-success' : 'label-danger';
    switch ($searchModel->status) {
        case $searchModel::STATUS_PUBLISHED:
            $class = 'label-success';
            break;
        case $searchModel::STATUS_UNPUBLISHED:
            $class = 'label-info';
            break;
        case $searchModel::STATUS_BANNED:
            $class = 'label-danger';
            break;
        case $searchModel::STATUS_NOT_MODERATING:
            $class = 'label-warning';
            break;
    }
    return '<span class="label ' . $class . '">' . $searchModel->getStatus() . '</span>';
}, 'class' => \mcms\xeditable\XEditableColumn::className(), 'url' => \yii\helpers\Url::toRoute('editable'), 'dataType' => 'select', 'editable' => ['source' => [['value' => 0, 'text' => 'not moderating'], ['value' => 1, 'text' => 'published'], ['value' => 2, 'text' => 'unpublished'], ['value' => 3, 'text' => 'banned']], 'placement' => 'inline'], 'format' => 'raw', 'filter' => Html::activeDropDownList($searchModel, 'status', $statusArray, ['class' => 'form-control', 'prompt' => '--Select--'])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>