|
- <?php
-
-
-
- use domain\Setting\SettingModule;
- use lo\widgets\Toggle;
- use yii\bootstrap\ActiveForm;
- use yii\helpers\Html;
-
- $settingModule = SettingModule::getInstance();
- $adminSettingDefinition = $settingModule->getAdminSettingDefinition();
-
- $this->setTitle('Paramètres');
- $this->addBreadcrumb($this->getTitle());
-
- ?>
-
- <script>
- var appInitValues = {
- sectionsArray: <?php echo json_encode($adminSettingDefinition->getSectionsArray()); ?>,
- };
- </script>
-
- <div class="setting-admin-index setting-form" id="app-setting-admin">
-
- <div id="nav-params">
- <a v-for="section in sectionsArray" :class="'btn '+((currentSection == section.name) ? 'btn-primary' : 'btn-default')"
- @click="changeSection(section)" :href="'#'+section.name">
- {{ section.nameDisplay }}
- </a>
- </div>
-
- <?php $form = ActiveForm::begin(); ?>
- <?php foreach($adminSettingDefinition->getSettingDetails() as $sectionName => $sectionsArray): ?>
- <div v-show="currentSection == '<?= $sectionName ?>'" class="panel panel-default">
- <div class="panel-body">
- <?php foreach($sectionsArray as $subSectionName => $subSectionsArray): ?>
- <h4><?php echo $adminSettingDefinition->getSectionLabelBySectionName($subSectionName); ?></h4>
- <?php foreach($subSectionsArray as $settingDetail): ?>
- <?php echo field($form, $model, $settingDetail); ?>
- <?php endforeach; ?>
- <?php endforeach; ?>
- </div>
- </div>
- <?php endforeach; ?>
- <div class="form-group">
- <?= Html::submitButton('Sauvegarder', ['class' => 'btn btn-primary']) ?>
- </div>
- <?php ActiveForm::end(); ?>
- </div>
-
- <?php
-
- function field($form, $model, $settingDetail) {
- $field = $form->field($model, $settingDetail->getName());
- if($settingDetail->getFormType() == 'checkbox') {
- $field = $field->checkbox();
- }
- elseif($settingDetail->getFormType() == 'toggle') {
- $field = $form->field($model, $settingDetail->getName(), ['options' => ['class' => 'form-group form-toggle']])->widget(Toggle::class, ['options' => ['data-on' => 'Oui', 'data-off' => 'Non', 'data-offstyle' => 'danger']]);
- }
- elseif($settingDetail->getFormType() == 'select') {
- $field = $field->dropDownList($settingDetail->getOptions());
- }
- elseif($settingDetail->getFormType() == 'textarea') {
- $field = $field->textarea(['rows' => 4]);
- }
- elseif($settingDetail->getFormType() == 'input') {
- $field = $field->textInput();
- }
- else {
- return '<div class="form-group"><span class="glyphicon glyphicon-alert"></span> Type de champ non défini pour le paramètre "'.$settingDetail->getName().'"</div>';
- }
-
- if($settingDetail->getHelpMessage()) {
- $field->hint($settingDetail->getHelpMessage());
- }
-
- return $field;
- }
-
- ?>
|