コード例 #1
0
ファイル: index.php プロジェクト: deka6pb/yii2-autoparser
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Posts', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'rowOptions' => function ($model) {
    if ($model->status == $model::STATUS_PUBLISHED) {
        return ['class' => 'success'];
    } elseif ($model->status == $model::STATUS_STOPPED) {
        return ['class' => 'danger'];
    }
}, 'columns' => [['attribute' => 'id', 'options' => ['width' => '30']], ['attribute' => 'type', 'options' => ['width' => '30']], 'text:ntext', ['attribute' => 'status', 'format' => 'html', 'filter' => Html::activeDropDownList($searchModel, 'status', Posts::getStatusAliases(), ['class' => 'form-control']), 'options' => ['width' => '30'], 'value' => function ($model) {
    return $model->getStatus();
}], ['attribute' => 'tags', 'options' => ['width' => '35']], ['attribute' => 'sid', 'options' => ['width' => '35']], ['attribute' => 'provider', 'options' => ['width' => '35']], ['attribute' => 'created', 'format' => ['date', 'php:Y-m-d H:i'], 'options' => ['width' => '200'], 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'created', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'published', 'format' => ['date', 'php:Y-m-d H:i'], 'options' => ['width' => '200'], 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'published', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'url', 'format' => 'raw', 'options' => ['width' => '80'], 'value' => function ($model) {
    return Html::a('Go Link', $model->url, ['title' => $model->url]);
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
コード例 #2
0
ファイル: _form.php プロジェクト: deka6pb/yii2-autoparser
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

    <?php 
echo $form->field($model, 'type')->dropDownList(Posts::getTypesAliases(), ['prompt' => '']);
?>

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

    <?php 
if (!$model->isNewRecord) {
    ?>
        <?php 
    echo $form->field($model, 'status')->dropDownList(Posts::getStatusAliases(), ['prompt' => '']);
    ?>
    <?php 
}
?>

    <?php 
echo $form->field($model, 'tags')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'uploadFiles[]')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*', 'multiple' => true], 'pluginOptions' => ["allowedFileExtensions" => ["jpg", "png", "gif"], 'initialPreview' => $model->getHtmlImagesArray(), 'overwriteInitial' => true]]);
?>

    <div class="form-group">
        <?php