Exemple #1
0
        <?php 
echo Html::a(Yii::t('backend/section', 'Create {modelClass}', ['modelClass' => 'Section']), ['create'], ['class' => 'btn btn-success']);
?>
        <?php 
echo Html::a(Yii::t('backend/section', 'Sort {modelClass}', ['modelClass' => 'Section']), ['toc'], ['class' => 'btn btn-primary']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model, $key, $index, $grid) {
    return ['data' => ['sectionver' => $model->ver]];
}, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'title', 'value' => function ($model, $key, $index, $column) {
    return Html::a($model->title, ['article/view', 'id' => $key]);
}, 'format' => 'raw'], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'status', 'value' => function ($model, $key, $index, $column) {
    return Html::dropDownList('status' . $key, $model->status, $model->getAllStatus(), ['class' => 'stauts-dropdown', 'data' => ['sectionfield' => 'status']]);
}, 'format' => 'raw', 'filter' => Section::getAllStatus()], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'toc_mode', 'value' => function ($model, $key, $index, $column) {
    return Html::dropDownList('toc_mode' . $key, $model->toc_mode, $model->getAllTocMode(), ['class' => 'toc_mode-dropdown', 'data' => ['sectionfield' => 'toc_mode']]);
}, 'format' => 'raw', 'filter' => Section::getAllTocMode()], ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'comment_mode', 'value' => function ($model, $key, $index, $column) {
    return Html::dropDownList('comment_mode' . $key, $model->comment_mode, $model->getAllCommentMode(), ['class' => 'comment_mode-dropdown', 'data' => ['sectionfield' => 'comment_mode']]);
}, 'format' => 'raw', 'filter' => Section::getAllCommentMode()], 'updated_at:datetime', ['class' => 'yii\\grid\\DataColumn', 'attribute' => 'created_by', 'value' => function ($model, $key, $index, $column) {
    if ($model->getCreatedBy() === null) {
        return '';
    }
    return $model->getCreatedBy()->one()->username;
}, 'filter' => false], ['class' => 'yii\\grid\\ActionColumn', 'header' => Yii::t('backend/section', 'Operation'), 'buttons' => ['delete' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', 'javascript:void(0);', ['title' => Yii::t('backend/section', 'Delete'), 'class' => 'lnk-del-section']);
}]]]]);
?>

</div>
Exemple #2
0
<?php

use backend\assets\ArticleUpdateAsset;
use common\models\Section;
use yii\web\View;
use yii\helpers\Json;
/* @var $this yii\web\View */
/* @var $model common\models\Article */
/* @var $sections array */
$items = [];
$allTags = ['toc_mode' => Section::getAllTocMode(), 'comment_mode' => Section::getAllCommentMode()];
foreach ($allTags as $field => $fieldTags) {
    $tmpTags = [];
    foreach ($fieldTags as $k => $s) {
        $tmpTags[] = ['value' => strval($k), 'label' => $s];
    }
    $fieldTitle = $model->attributeLabels()[$field];
    $items[$field] = ['label' => $fieldTitle, 'title' => $fieldTitle, 'groups' => [['label' => $fieldTitle, 'tags' => $tmpTags]]];
}
$js = 'window.digpage=window.digpage||{};window.digpage.update_dropdown_items = ' . Json::encode($items) . ';';
$this->registerJs($js, View::POS_END);
ArticleUpdateAsset::register($this);
$this->title = Yii::t('backend/section', 'Update {modelClass}: ', ['modelClass' => 'Section']) . ' ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('backend/section', 'Sections'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('backend/section', 'Update');
?>
<div class="section-update">
<?php 
echo $this->render('_update', ['sections' => $sections, 'rootId' => $model->id, 'level' => 1]);
?>
Exemple #3
0
/* @var $form yii\widgets\ActiveForm */
ArticleFormAsset::register($this);
?>

<div class="section-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <?php 
echo $form->field($model, 'content')->textarea(['rows' => 6]);
?>

    <?php 
echo $form->field($model, 'toc_mode')->dropDownList(Section::getAllTocMode());
?>

    <?php 
echo $form->field($model, 'comment_mode')->dropDownList(Section::getAllCommentMode());
?>
    
    <?php 
echo Html::hiddenInput('isPublish', 0, ['id' => 'hdn-ispublish']);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton(Yii::t('backend/section', 'Create'), ['class' => 'btn btn-primary']);
?>
        <?php