public function api_begin($options = []) { $options = array_merge($this->_defaultFormOptions, $options); $moduleName = FeedbackModule::getModuleName(FeedbackModule::className()); if (isset($options['successUrl'])) { $successUrl = $options['successUrl']; unset($options['successUrl']); } else { $successUrl = Url::current(); } if (isset($options['errorUrl'])) { $errorUrl = $options['errorUrl']; unset($options['errorUrl']); } else { $errorUrl = Url::current(); } $form = ActiveForm::begin(ArrayHelper::merge($options, ['enableClientValidation' => true, 'action' => Url::to(['/admin/' . $moduleName . '/send'])])); echo Html::hiddenInput('errorUrl', $errorUrl); echo Html::hiddenInput('successUrl', $successUrl); return $form; }
public function init() { parent::init(); $moduleName = FeedbackModule::getModuleName(FeedbackModule::className()); $this->new = Yii::$app->getModule('admin')->activeModules[$moduleName]->notice; $this->noAnswer = Feedback::find()->status(Feedback::STATUS_VIEW)->count(); }
<?php use understeam\easyii\feedback\FeedbackModule; use understeam\easyii\feedback\models\Feedback; $this->title = Yii::t('understeam/feedback', 'Feedback'); $module = $this->context->module->id; ?> <?php echo $this->render('_menu'); ?> <?php $columns = [['attribute' => 'primaryKey', 'header' => '#', 'headerOptions' => ['style' => ['width' => '30px']]]]; $gridColumns = FeedbackModule::getGridColumns(); if (count($gridColumns)) { $columns = array_merge($columns, $gridColumns); } $columns = array_merge($columns, [['attribute' => 'time', 'format' => ['datetime', 'short']], ['attribute' => 'answer', 'format' => 'raw', 'value' => function (Feedback $model) { if ($model->status == Feedback::STATUS_ANSWERED) { return "<span class=\"text-success\">" . Yii::t('easyii', 'Yes') . "</span>"; } else { return "<span class=\"text-danger\">" . Yii::t('easyii', 'No') . "</span>"; } }, 'headerOptions' => ['style' => ['width' => '40px']]], ['format' => 'raw', 'value' => function (Feedback $model) use($module) { return \yii\helpers\Html::a("", ['/admin/' . $module . '/a/view', 'id' => $model->primaryKey], ['class' => 'glyphicon glyphicon-eye-open', 'title' => Yii::t('easyii', 'View item')]); }, 'headerOptions' => ['style' => ['width' => '30px']]], ['format' => 'raw', 'value' => function (Feedback $model) use($module) { return \yii\helpers\Html::a("", ['/admin/' . $module . '/a/delete', 'id' => $model->primaryKey], ['class' => 'glyphicon glyphicon-remove confirm-delete', 'title' => Yii::t('easyii', 'Delete item')]); }, 'headerOptions' => ['style' => ['width' => '30px']]]]); echo \yii\grid\GridView::widget(['dataProvider' => $data, 'layout' => '{items}{pager}', 'tableOptions' => ['class' => 'table table-hover'], 'columns' => $columns]);
public function __set($name, $value) { $fields = FeedbackModule::getFormFields(); if (isset($fields[$name])) { $data = $this->getData(); $data[$name] = $value; $this->setData($data); return; } parent::__set($name, $value); }