/**
  * Show form (usually via AJAX) for feedback
  *
  * @param null|int $id parent feedback ID (for comments)
  *
  * @throws \yii\web\NotFoundHttpException
  * @throws \yii\web\BadRequestHttpException
  * @return string
  */
 public function actionSendFeedback($id = null)
 {
     if ($id) {
         $parent = Feedback::findOne(['id' => $id, 'status' => Feedback::STATUS_APPROVED]);
         if (!$parent) {
             throw new NotFoundHttpException(FeedbackModule::t('front', 'Отзыв не найден'));
         }
     }
     $model = new Feedback();
     if ($model->load(Yii::$app->request->post())) {
         $model->parent_id = isset($parent) ? $parent->id : null;
         $model->status = Feedback::STATUS_PENDING;
         $model->admin_comment = 0;
         if ($model->save()) {
             Yii::$app->session->setFlash('success', FeedbackModule::t('front', 'Спасибо за Ваш отзыв !'));
             $this->redirect(['index']);
         }
     }
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax('sendFeedback', compact('model', 'id'));
     } else {
         return $this->render('sendFeedback', compact('model', 'id'));
     }
 }
use yii\helpers\Html;
?>

<div class="feedback-item-wrapper">

	<?php 
echo $this->render('_feedbackBody', ['model' => $model]);
?>

	<?php 
if ($this->context->module->hasComments) {
    ?>

		<div class="feedback-footer text-right">
			<?php 
    echo Html::a(FeedbackModule::t('front', 'Комментировать'), ['send-feedback', 'id' => $model->id], ['class' => 'btn btn-default btn-sm fancybox fancybox.ajax']);
    ?>
		</div>

		<?php 
    if ($model->comments) {
        ?>

			<div class="feedback-comments">
				<?php 
        foreach ($model->comments as $comment) {
            ?>
					<div class="row">
						<div class="col-xs-50 col-xs-offset-10">
							<?php 
            echo $this->render('_feedbackBody', ['model' => $comment]);
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<div class="feedback-form-container">
	<div class="col-xs-60" style="width: 500px">
		<?php 
$form = ActiveForm::begin(['id' => 'feedback-form', 'options' => ['class' => 'form-horizontal']]);
?>

		<?php 
echo $form->field($model, 'name');
?>
		<?php 
echo $form->field($model, 'title');
?>
		<?php 
echo $form->field($model, 'body')->textarea(['rows' => 10]);
?>

		<div class="form-group">
			<?php 
echo Html::submitButton($id ? FeedbackModule::t('front', 'Оставить комментарий') : FeedbackModule::t('front', 'Оставить отзыв'), ['class' => 'btn btn-primary']);
?>
		</div>
		<?php 
ActiveForm::end();
?>

	</div>
</div>
Exemple #4
0
    ?>
	<?php 
}
?>

	<h2 class="feedback-title text-center"><?php 
echo $this->title;
?>
</h2>

	<?php 
if ($this->beginCache('__feedbackList', ['duration' => 3600 * 24, 'variations' => [Yii::$app->request->get('page'), Yii::$app->language], 'dependency' => ['class' => 'yii\\caching\\DbDependency', 'sql' => 'SELECT MAX(updated_at) FROM feedback']])) {
    ?>
		<?php 
    echo ListView::widget(['dataProvider' => $provider, 'itemView' => '_itemView', 'layout' => "{items}\n{pager}", 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'lastPageLabel' => '>>', 'firstPageLabel' => '<<']]);
    ?>

	<?php 
    $this->endCache();
}
?>
</div>

<div class="send-feedback-btn">
	<?php 
echo Html::a(FeedbackModule::t('front', 'Оставить отзыв'), ['/feedback/default/send-feedback'], ['class' => 'btn btn-default fancybox fancybox.ajax']);
?>
</div>

<?php 
Fancybox::widget();
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => 'ID', 'status' => 'Статус', 'parent_id' => 'Parent ID', 'name' => FeedbackModule::t('front', 'Автор'), 'title' => FeedbackModule::t('front', 'Заголовок'), 'body' => FeedbackModule::t('front', 'Текст'), 'admin_comment' => 'От админа', 'created_at' => 'Создано', 'updated_at' => 'Обновлено'];
 }