예제 #1
1
 public function api_form()
 {
     $model = new GuestbookModel();
     $settings = Yii::$app->getModule('admin')->activeModules['guestbook']->settings;
     ob_start();
     $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/guestbook/send'])]);
     switch (Yii::$app->session->getFlash(GuestbookModel::FLASH_KEY)) {
         case 'success':
             $message = Yii::$app->getModule('admin')->activeModules['guestbook']->settings['preModerate'] ? Yii::t('easyii/guestbook/api', 'Message successfully sent and will be published after moderation') : Yii::t('easyii/guestbook/api', 'Message successfully added');
             echo Alert::widget(['options' => ['class' => 'alert-success'], 'body' => $message]);
             break;
         case 'error':
             echo Alert::widget(['options' => ['class' => 'alert-danger'], 'body' => Yii::t('easyii/guestbook/api', 'An error has occurred')]);
             break;
     }
     echo $form->field($model, 'name');
     if ($settings['enableTitle']) {
         echo $form->field($model, 'title');
     }
     echo $form->field($model, 'text')->textarea();
     if ($settings['enableCaptcha']) {
         echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
     }
     echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
     ActiveForm::end();
     return ob_get_clean();
 }
예제 #2
0
 public function api_form($options = [])
 {
     $model = new FeedbackModel();
     $settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings;
     $options = array_merge($this->_defaultFormOptions, $options);
     ob_start();
     $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]);
     echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0]));
     echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1]));
     echo $form->field($model, 'name');
     echo $form->field($model, 'email')->input('email');
     if ($settings['enablePhone']) {
         echo $form->field($model, 'phone');
     }
     if ($settings['enableTitle']) {
         echo $form->field($model, 'title');
     }
     echo $form->field($model, 'text')->textarea();
     if ($settings['enableCaptcha']) {
         echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
     }
     echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
     ActiveForm::end();
     return ob_get_clean();
 }
예제 #3
-1
 public function api_form($options = [])
 {
     $model = new FeedbackModel();
     $settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings;
     $options = array_merge($this->_defaultFormOptions, $options);
     ob_start();
     $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send']), 'options' => ['class' => 'col form']]);
     echo '<p class="caption">' . Text::get('contact-page-leave-us-a-message') . '</p>';
     echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0]));
     echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1]));
     echo $form->field($model, 'name', ['options' => ['tag' => 'fieldset'], 'errorOptions' => ['class' => 'msg-error', 'tag' => 'p'], 'template' => '{input}{error}', 'selectors' => ['input' => '#input-001']])->input('text', ['id' => 'input-001', 'placeholder' => Yii::t('all', 'Name')]);
     echo $form->field($model, 'email', ['options' => ['tag' => 'fieldset'], 'errorOptions' => ['class' => 'msg-error', 'tag' => 'p'], 'template' => '{input}{error}', 'selectors' => ['input' => '#input-002']])->input('email', ['id' => 'input-002', 'placeholder' => Yii::t('all', 'Your e-mail')]);
     if ($settings['enablePhone']) {
         echo $form->field($model, 'phone');
     }
     if ($settings['enableTitle']) {
         echo $form->field($model, 'title');
     }
     echo $form->field($model, 'text', ['options' => ['tag' => 'fieldset'], 'errorOptions' => ['class' => 'msg-error', 'tag' => 'p'], 'template' => '{input}{error}', 'selectors' => ['input' => '#input-005']])->textArea(['rows' => '6', 'id' => 'input-005', 'placeholder' => Yii::t('all', 'Message text')]);
     if ($settings['enableCaptcha']) {
         echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
     }
     echo Html::submitButton(Yii::t('all', 'send a message'), ['class' => 'btn btn-primary']);
     ActiveForm::end();
     return ob_get_clean();
 }
예제 #4
-1
 public function api_form()
 {
     $model = new FeedbackModel();
     $settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings;
     ob_start();
     $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]);
     switch (Yii::$app->session->getFlash(FeedbackModel::FLASH_KEY)) {
         case 'success':
             echo Alert::widget(['options' => ['class' => 'alert-success'], 'body' => Yii::t('easyii/feedback/api', 'Feedback send. We will answer you soon')]);
             break;
         case 'error':
             echo Alert::widget(['options' => ['class' => 'alert-danger'], 'body' => Yii::t('easyii/feedback/api', 'An error has occurred')]);
             break;
     }
     echo $form->field($model, 'name');
     echo $form->field($model, 'email')->input('email');
     if ($settings['enablePhone']) {
         echo $form->field($model, 'phone');
     }
     if ($settings['enableTitle']) {
         echo $form->field($model, 'title');
     }
     echo $form->field($model, 'text')->textarea();
     if ($settings['enableCaptcha']) {
         echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className());
     }
     echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']);
     ActiveForm::end();
     return ob_get_clean();
 }