Example #1
0
 /**
  * Returns the language name by its code
  * @return mixed
  */
 public function getLanguageLabel()
 {
     return Language::getLangByCode($this->language);
 }
Example #2
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use kartik\file\FileInput;
use kartik\select2\Select2;
use kartik\switchinput\SwitchInput;
use app\helpers\Timezone;
use app\helpers\Language;
// Lnaguages array
$languages = Language::supportedLanguages();
// Timezone array
$timezones = Timezone::all();
//array_unshift($timezones, "Choose Your Time Zone");
/** @var \app\modules\user\models\Role $role */
$role = Yii::$app->getModule("user")->model("Role");
/**
 * @var yii\web\View $this
 * @var app\modules\user\models\User $user
 * @var app\models\Profile $profile
 * @var yii\widgets\ActiveForm $form
 * @var array $forms [id => name] of forms
 * @var array $userForms Form ids of the selected user
 */
?>

<div class="user-form">

    <?php 
$form = ActiveForm::begin();
?>
Example #3
0
                        <?php 
echo Yii::t('app', 'Notification Settings');
?>
</a></li>
                <li role="presentation">
                    <a href="#form_theme_settings" aria-controls="form_theme_settings" role="tab" data-toggle="tab">
                        <?php 
echo Yii::t('app', 'UI Settings');
?>
</a></li>
            </ul>
            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane fade in active" id="form_settings">
                    <?php 
echo FormGrid::widget(['model' => $formModel, 'form' => $form, 'autoGenerateColumns' => true, 'columnSize' => Form::SIZE_TINY, 'rows' => [['contentBefore' => Html::tag('legend', Yii::t('app', 'Form Settings'), ['class' => 'text-primary']), 'attributes' => ['name' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter the form name...")]]]], ['attributes' => ['status' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => Yii::t("app", "Disables the form at any time.")], 'language' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'hint' => Yii::t("app", "This language will be used to display your form messages."), 'options' => ['data' => \app\helpers\Language::supportedLanguages()]]]], ['attributes' => ['message' => ['type' => Form::INPUT_TEXTAREA, 'hint' => Yii::t("app", "Message displayed to the user when the form is disabled."), 'options' => ['placeholder' => Yii::t("app", "Enter message...")]]]], ['attributes' => ['schedule' => ['type' => Form::INPUT_RAW, 'value' => $form->field($formModel, 'schedule')->radioButtonGroup([$formModel::ON => Yii::t('app', 'Yes'), $formModel::OFF => Yii::t('app', 'No')], ['itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary']], 'style' => 'display:block; margin-bottom:15px; overflow:hidden'])]]], ['attributes' => ['schedule_start_date' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => \kartik\datecontrol\DateControl::className(), 'options' => ['type' => \kartik\datecontrol\DateControl::FORMAT_DATETIME, 'displayTimezone' => Yii::$app->timeZone, 'options' => ['options' => ['placeholder' => 'Select start date...']]]], 'schedule_end_date' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => \kartik\datecontrol\DateControl::className(), 'options' => ['type' => \kartik\datecontrol\DateControl::FORMAT_DATETIME, 'displayTimezone' => Yii::$app->timeZone, 'options' => ['options' => ['placeholder' => 'Select end date...']]]]]], ['contentBefore' => Html::tag('legend', Yii::t('app', 'Advanced Options'), ['class' => 'text-primary']), 'attributes' => ['save' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => Yii::t("app", "Saves all form submissions in the database.")], 'analytics' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => Yii::t("app", "Enable Form Tracking.")], 'honeypot' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => Yii::t("app", "Adds a hidden text field to filter spam.")], 'resume' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => Yii::t("app", "Auto save incomplete form filling and resume later.")]]], ['contentBefore' => Html::tag('legend', Yii::t('app', 'Submission Limit'), ['class' => 'text-primary']), 'attributes' => ['total_limit' => ['type' => Form::INPUT_RAW, 'value' => $form->field($formModel, 'total_limit')->radioButtonGroup([$formModel::ON => Yii::t('app', 'Yes'), $formModel::OFF => Yii::t('app', 'No')], ['itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary']], 'style' => 'display:block; margin-bottom:15px; overflow:hidden'])]]], ['attributes' => ['total_limit_number' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter the total number...")]], 'total_limit_period' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'options' => ['data' => $formModel->getTimePeriods(), 'pluginOptions' => ['placeholder' => Yii::t('app', 'Select time period'), 'allowClear' => true]]]]], ['attributes' => ['ip_limit' => ['type' => Form::INPUT_RAW, 'value' => $form->field($formModel, 'ip_limit')->radioButtonGroup([$formModel::ON => Yii::t('app', 'Yes'), $formModel::OFF => Yii::t('app', 'No')], ['itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary']], 'style' => 'display:block; margin-bottom:15px; overflow:hidden'])]]], ['attributes' => ['ip_limit_number' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter the max number...")]], 'ip_limit_period' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'options' => ['data' => $formModel->getTimePeriods(), 'pluginOptions' => ['placeholder' => Yii::t('app', 'Select time period'), 'allowClear' => true]]]]]]]);
?>
                </div>
                <div role="tabpanel" class="tab-pane fade" id="form_confirmation_settings">
                    <?php 
echo FormGrid::widget(['model' => $formConfirmationModel, 'form' => $form, 'autoGenerateColumns' => true, 'rows' => [['contentBefore' => Html::tag('legend', Yii::t('app', 'Confirmation Settings'), ['class' => 'text-primary']), 'attributes' => ['type' => ['type' => Form::INPUT_RAW, 'value' => $form->field($formConfirmationModel, 'type')->radioButtonGroup($formConfirmationModel->getTypes(), ['itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary']], 'style' => 'display:block; margin-bottom:15px; overflow:hidden'])]]], ['attributes' => ['message' => ['type' => Form::INPUT_TEXTAREA, 'options' => ['placeholder' => Yii::t("app", "Your Confirmation Message...")]]]], ['attributes' => ['url' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter URL...")]]]], ['attributes' => ['send_email' => ['type' => Form::INPUT_RAW, 'value' => $form->field($formConfirmationModel, 'send_email')->radioButtonGroup([$formConfirmationModel::CONFIRM_BY_EMAIL_ENABLE => Yii::t('app', 'Yes'), $formConfirmationModel::CONFIRM_BY_EMAIL_DISABLE => Yii::t('app', 'No')], ['itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary']], 'style' => 'display:block; margin-bottom:15px; overflow:hidden'])]]], ['attributes' => ['mail_to' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'hint' => Yii::t("app", "Your form must have an email field to use this feature."), 'options' => ['data' => $emailFields, 'options' => ['placeholder' => Yii::t("app", "Select an e-mail field...")], 'pluginOptions' => ['allowClear' => true]]], 'mail_from' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter your e-mail address...")]], 'mail_from_name' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter your name or company...")]]]], ['attributes' => ['mail_subject' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter subject...")]]]], ['attributes' => ['mail_message' => ['type' => Form::INPUT_TEXTAREA, 'hint' => Yii::t("app", "Allowed HTML Tags:") . ' ' . Html::encode('<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'), 'options' => ['placeholder' => Yii::t("app", "Your Confirmation Message by E-Mail...")]]]], ['attributes' => ['mail_receipt_copy' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => '']]]]]);
?>
                </div>
                <div role="tabpanel" class="tab-pane fade" id="form_notification_settings">
                    <?php 
echo FormGrid::widget(['model' => $formEmailModel, 'form' => $form, 'autoGenerateColumns' => true, 'rows' => [['contentBefore' => Html::tag('legend', Yii::t('app', 'To Email Address'), ['class' => 'text-primary']), 'attributes' => ['subject' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter subject...")]]]], ['attributes' => ['to' => ['type' => Form::INPUT_TEXT, 'hint' => Yii::t("app", "Notifications wil be e-mailed to this address, e.g. '*****@*****.**'."), 'options' => ['placeholder' => Yii::t("app", "Enter e-mail address...")]], 'from' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'options' => ['data' => $emails]]]], ['attributes' => ['cc' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter e-mail address...")]], 'bcc' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => Yii::t("app", "Enter e-mail address...")]]]], ['autoGenerateColumns' => false, 'columns' => 12, 'attributes' => ['type' => ['columnOptions' => ['colspan' => 6], 'type' => Form::INPUT_RAW, 'value' => $form->field($formEmailModel, 'type')->radioButtonGroup([$formEmailModel::TYPE_ALL => Yii::t("app", "All Data"), $formEmailModel::TYPE_LINK => Yii::t("app", "Only Link"), $formEmailModel::TYPE_MESSAGE => Yii::t("app", "Custom Message")], ['itemOptions' => ['labelOptions' => ['class' => 'btn btn-primary']], 'style' => 'display:block; margin-bottom:15px; overflow:hidden'])->hint(Yii::t("app", "This email may contain all submitted data,\n                                            a link to saved data or a custom message."))], 'attach' => ['columnOptions' => ['colspan' => 3], 'type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => ''], 'plain_text' => ['columnOptions' => ['colspan' => 3], 'type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\switchinput\\SwitchInput', 'hint' => '']]], ['attributes' => ['message' => ['type' => Form::INPUT_TEXTAREA, 'hint' => Yii::t("app", "Allowed HTML Tags:") . ' ' . Html::encode('<a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>'), 'options' => ['placeholder' => Yii::t("app", "Enter your custom message...")]]]]]]);
?>
                </div>
                <div role="tabpanel" class="tab-pane fade" id="form_theme_settings">
                    <?php 
echo FormGrid::widget(['model' => $formUIModel, 'form' => $form, 'autoGenerateColumns' => true, 'columnSize' => Form::SIZE_TINY, 'rows' => [['contentBefore' => Html::tag('legend', Yii::t('app', 'UI Settings'), ['class' => 'text-primary']), 'attributes' => ['js_file' => ['type' => Form::INPUT_TEXT, 'hint' => Yii::t("app", "This custom javascript file will be loaded each time the form is being displayed."), 'options' => ['placeholder' => Yii::t("app", "Enter URL...")]]]], ['attributes' => ['theme_id' => ['type' => Form::INPUT_WIDGET, 'widgetClass' => '\\kartik\\select2\\Select2', 'label' => Yii::t('app', 'Select a Theme'), 'hint' => Yii::t("app", "Select the theme that fits best to your form."), 'options' => ['data' => $themes, 'pluginOptions' => ['placeholder' => Yii::t('app', 'Select a Theme'), 'allowClear' => true], 'pluginEvents' => ["select2:select" => "previewSelected", "select2:unselect" => "previewUnselected"]]]]]]]);