예제 #1
0
 public function search($params)
 {
     $query = Organizer::find()->indexBy('id');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name' => SORT_ASC]], 'pagination' => ['pageSize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
예제 #2
0
<?php

use yii\helpers\Html;
use app\components\grid\GridView;
use yii\widgets\Pjax;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use app\models\Organizer;
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var app\models\search\PollSearch $searchModel
 */
$columns = [['class' => 'app\\components\\grid\\ActionColumn'], 'title', 'question:ntext', 'membersCount', 'start_time:datetime', 'end_time:datetime', ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'locked', 'format' => 'boolean', 'visible' => \Yii::$app->user->isAdmin(), 'refreshGrid' => true, 'editableOptions' => ['header' => \Yii::t('app', 'locked') . ' (admin only)', 'size' => 'md', 'data' => array(0 => 'Open', 1 => 'Locked'), 'inputType' => \kartik\editable\Editable::INPUT_DROPDOWN_LIST, 'formOptions' => ['action' => Url::to(['ajax-update'])], 'displayValueConfig' => [0 => 'Open', 1 => 'Locked'], 'containerOptions' => ['style' => 'text-align: center; display:block;']]], ['attribute' => 'organizer_id', 'width' => '180px', 'format' => 'raw', 'visible' => \Yii::$app->user->isAdmin(), 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Organizer::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => \Yii::t('app', 'Any Organizer')], 'value' => function ($data, $key, $index, $widget) {
    return $this->render('//system/columnviews/_organizer', ['data' => $data->organizer]);
}]];
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $columns, 'id' => 'poll_grid']);
예제 #3
0
use yii\helpers\Html;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use kartik\datecontrol\DateControl;
use yii\helpers\ArrayHelper;
use app\models\Organizer;
/**
 * @var yii\web\View $this
 * @var app\models\User $model
 * @var kartik\widgets\ActiveForm $form
 */
?>
<div class="user-form">
<?php 
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_VERTICAL]);
echo $form->errorSummary([$model]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['username' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t('app', 'Enter Username...'), 'maxlength' => true]], 'new_password' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t('app', 'Enter Password to set one'), 'maxlength' => true]], 'is_admin' => ['type' => Form::INPUT_CHECKBOX, 'options' => ['placeholder' => Yii::t('app', 'Enter Is Admin...')]], 'organizer_id' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Organizer::find()->all(), 'id', 'name'), 'options' => ['prompt' => Yii::t('app', 'None')]]]]);
?>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
        </div>
    </div>
<?php 
ActiveForm::end();
?>
</div>
예제 #4
0
<?php

use yii\helpers\Html;
use app\components\grid\GridView;
use yii\widgets\Pjax;
use yii\helpers\ArrayHelper;
use app\models\Organizer;
/**
 * @var yii\web\View $this
 * @var yii\data\ActiveDataProvider $dataProvider
 * @var app\models\search\UserSearch $searchModel
 */
$columns = [['class' => 'app\\components\\grid\\ActionColumn'], 'username', ['class' => '\\kartik\\grid\\BooleanColumn', 'attribute' => 'is_admin', 'trueLabel' => Yii::t('app', 'Yes'), 'falseLabel' => Yii::t('app', 'No'), 'headerOptions' => ['style' => 'white-space: nowrap;']], ['attribute' => 'organizer_id', 'header' => \Yii::t('app', 'Organizer'), 'format' => 'raw', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Organizer::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => \Yii::t('app', 'Any Organizer')], 'value' => function ($data, $key, $index, $widget) {
    return $this->render('//system/columnviews/_organizer', ['data' => $data->organizer]);
}], 'creator', 'editor'];
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $columns]);
예제 #5
0
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
use kartik\datecontrol\DateControl;
use yii\helpers\ArrayHelper;
use app\models\Organizer;
/**
 * @var yii\web\View $this
 * @var app\models\Poll $model
 * @var kartik\widgets\ActiveForm $form
 */
?>
<div class="poll-form">
<?php 
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_VERTICAL]);
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 1, 'attributes' => ['title' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t('app', 'Enter Title...'), 'maxlength' => 255]], 'question' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => Yii::t('app', 'Enter Question...'), 'rows' => 6]], 'info' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => Yii::t('app', 'Enter Additional Information...'), 'rows' => 3]]]]);
if (\Yii::$app->user->isAdmin()) {
    echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 2, 'attributes' => ['organizer_id' => ['type' => Form::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(Organizer::find()->all(), 'id', 'name'), 'options' => ['prompt' => Yii::t('app', 'None')]]]]);
}
echo Form::widget(['model' => $model, 'form' => $form, 'columns' => 2, 'attributes' => ['select_min' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t('app', 'Enter Select Min...')]], 'select_max' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t('app', 'Enter Select Max...')]], 'start_time' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => DateControl::classname(), 'options' => ['type' => DateControl::FORMAT_DATETIME, 'options' => ['pluginOptions' => ['todayHighlight' => true, 'initialDate' => date('Y-m-d H:i:00')]]]], 'end_time' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => DateControl::classname(), 'options' => ['type' => DateControl::FORMAT_DATETIME, 'options' => ['pluginOptions' => ['todayHighlight' => true, 'initialDate' => date('Y-m-d H:i:00')]]]]]]);
echo $this->render('_options_form', ['model' => $model, 'modelOptions' => $modelOptions, 'form' => $form]);
?>
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>
<?php 
ActiveForm::end();
?>
</div>