form option alignement + gabarit

This commit is contained in:
fredtempez 2022-01-20 09:33:29 +01:00
parent bd3e068095
commit bf8b71e4bf
3 changed files with 109 additions and 76 deletions

View File

@ -79,22 +79,26 @@ class form extends common {
'100' => '100%'
];
public static $formOffset = [
'none' => 'Aucune',
'1' => 'Une colonne',
'2' => 'Deux colonnes',
'3' => 'Trois colonnes',
'4' => 'Quatre colonnes',
public static $optionOffset = [
0 => 'Aucune',
1 => 'Une colonne',
2 => 'Deux colonnes'
];
public static $formWidth = [
'6' => 'Six colonne',
'7' => 'Sept colonnes',
'8' => 'Huit colonnes',
'9' => 'Neuf colonnes',
'10' => 'Dix colonnes',
'11' => 'Onze colonnes',
'12' => 'Douze colonnes',
public static $optionWidth = [
6 => 'Six colonnes',
7 => 'Sept colonnes',
8 => 'Huit colonnes',
9 => 'Neuf colonnes',
10 => 'Dix colonnes',
11 => 'Onze colonnes',
12 => 'Douze colonnes',
];
public static $optionAlign = [
'' => 'A gauche',
'textAlignCenter' => 'Au centre',
'textAlignRight' => 'A droite'
];
@ -156,6 +160,12 @@ class form extends common {
}
// Soumission du formulaire
if ($this->isPost()) {
// Débordement
$width = $this->getInput('formOptionWidth');
if ($this->getInput('formOptionWidth',helper::FILTER_INT) + $this->getInput('formOptionOffset',helper::FILTER_INT) > 12 ) {
$width = (string) $this->getInput('formOptionWidth',helper::FILTER_INT) - $this->getInput('formOptionOffset',helper::FILTER_INT);
}
// Configuration
$this->setData([
'module',
@ -172,7 +182,10 @@ class form extends common {
'replyto' => $this->getInput('formOptionMailReplyTo', helper::FILTER_BOOLEAN),
'signature' => $this->getInput('formOptionSignature'),
'logoUrl' => $this->getInput('formOptionLogo'),
'logoWidth' => $this->getInput('formOptionLogoWidth')
'logoWidth' => $this->getInput('formOptionLogoWidth'),
'offset' =>$this->getInput('formOptionOffset'),
'width' =>$width,
'align' =>$this->getInput('formOptionAlign'),
]
]);
// Génération des données vides
@ -181,7 +194,7 @@ class form extends common {
}
// Valeurs en sortie
$this->addOutput([
'notification' => 'Modifications enregistrées',
'notification' => 'Modifications enregistrées' ,
'redirect' => helper::baseUrl() . $this->getUrl(),
'state' => true
]);

View File

@ -1,5 +1,9 @@
<?php if($this->getData(['module', $this->getUrl(0), 'input'])): ?>
<div class="col10 offset1">
<div class="row <?php echo $this->getData(['module', $this->getUrl(0), 'config', 'align']);?>">
<div class="<?php
echo 'col' . $this->getData(['module', $this->getUrl(0), 'config', 'width']) . ' ';
echo $this->getData(['module', $this->getUrl(0), 'config', 'offset']) !== 0 ? 'offset' . $this->getData(['module', $this->getUrl(0), 'config', 'offset']) : '';
?>">
<?php echo template::formOpen('formForm'); ?>
<?php foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input): ?>
<?php if($input['type'] === $module::TYPE_MAIL): ?>
@ -63,7 +67,9 @@
</div>
</div>
</div>
<?php echo template::formClose(); ?>
</div>
</div>
<?php echo template::formClose(); ?>
<?php else: ?>
<?php echo template::speech('Le formulaire ne contient aucun champ.'); ?>
<?php endif; ?>

View File

@ -132,10 +132,24 @@
<h4>Gabarit</h4>
<div class="row">
<div class="col6">
<?php echo template::select('formOptionAlign', $module::$optionAlign, [
'label' => 'Alignement du formulaire',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'align'])
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php echo template::select('formOptionOffset', $module::$optionOffset, [
'label' => 'Décalage à gauche',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'offset'])
]); ?>
</div>
<div class="col6">
<?php echo template::select('formOptionWidth', $module::$optionWidth, [
'label' => 'Largeur',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'width'])
]); ?>
</div>
</div>
</div>