Initialisation des variables de session
This commit is contained in:
parent
abfe4cca2b
commit
9ba29fea30
|
@ -391,6 +391,17 @@ class form extends common {
|
||||||
$param = '';
|
$param = '';
|
||||||
$detectBot ='';
|
$detectBot ='';
|
||||||
include('./module/form/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_form.php');
|
include('./module/form/lang/'. $this->getData(['config', 'i18n', 'langAdmin']) . '/lex_form.php');
|
||||||
|
// Création du brouillon s'il n'existe pas
|
||||||
|
if( !isset($_SESSION['draft'])){
|
||||||
|
$_SESSION['draft'] = [];
|
||||||
|
$_SESSION['draft']['mail'] = "";
|
||||||
|
$_SESSION['draft']['textarea'] = "";
|
||||||
|
$_SESSION['draft']['datetime'] = null;
|
||||||
|
$_SESSION['draft']['checkbox'] = [];
|
||||||
|
$_SESSION['draft']['select'] = [];
|
||||||
|
$_SESSION['draft']['text'] = [];
|
||||||
|
$_SESSION['draft']['file'] = "";
|
||||||
|
}
|
||||||
// Soumission du formulaire
|
// Soumission du formulaire
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
// $notice concerne la pièce jointe et le captcha
|
// $notice concerne la pièce jointe et le captcha
|
||||||
|
@ -421,16 +432,6 @@ class form extends common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Création du brouillon s'il n'existe pas
|
|
||||||
if( $_SESSION['draft']===[] || $_SESSION['draft']===null){
|
|
||||||
$_SESSION['draft']['mail'] = "";
|
|
||||||
$_SESSION['draft']['textarea'] = "";
|
|
||||||
$_SESSION['draft']['datetime'] = null;
|
|
||||||
$_SESSION['draft']['checkbox'] = [];
|
|
||||||
$_SESSION['draft']['select'] = [];
|
|
||||||
$_SESSION['draft']['text'] = [];
|
|
||||||
$_SESSION['draft']['file'] = "";
|
|
||||||
}
|
|
||||||
// Mise à jour du brouillon
|
// Mise à jour du brouillon
|
||||||
$textIndex = 0; $selectIndex=0; $checkboxIndex=0;
|
$textIndex = 0; $selectIndex=0; $checkboxIndex=0;
|
||||||
for( $index = 0; $index <= count($this->getData(['module', $this->getUrl(0), 'input'])); $index++){
|
for( $index = 0; $index <= count($this->getData(['module', $this->getUrl(0), 'input'])); $index++){
|
||||||
|
|
|
@ -60,14 +60,14 @@ if($this->getData(['module', $this->getUrl(0), 'input'])): ?>
|
||||||
<?php echo template::select('formInput[' . $index . ']', $values, [
|
<?php echo template::select('formInput[' . $index . ']', $values, [
|
||||||
'id' => 'formInput_' . $index,
|
'id' => 'formInput_' . $index,
|
||||||
'label' => $input['name'],
|
'label' => $input['name'],
|
||||||
'selected' => $values[$_SESSION['draft']['select'][$selectIndex]]
|
'selected' => isset($_SESSION['draft']['select'][$selectIndex])? $values[$_SESSION['draft']['select'][$selectIndex]] : ''
|
||||||
]);
|
]);
|
||||||
$selectIndex++; ?>
|
$selectIndex++; ?>
|
||||||
<?php elseif($input['type'] === $module::TYPE_TEXT): ?>
|
<?php elseif($input['type'] === $module::TYPE_TEXT): ?>
|
||||||
<?php echo template::text('formInput[' . $index . ']', [
|
<?php echo template::text('formInput[' . $index . ']', [
|
||||||
'id' => 'formInput_' . $index,
|
'id' => 'formInput_' . $index,
|
||||||
'label' => $input['name'],
|
'label' => $input['name'],
|
||||||
'value' => $_SESSION['draft']['text'][$textIndex]
|
'value' => isset($_SESSION['draft']['text'][$textIndex]) ? $_SESSION['draft']['text'][$textIndex] : ''
|
||||||
]);
|
]);
|
||||||
$textIndex++; ?>
|
$textIndex++; ?>
|
||||||
<?php elseif($input['type'] === $module::TYPE_TEXTAREA): ?>
|
<?php elseif($input['type'] === $module::TYPE_TEXTAREA): ?>
|
||||||
|
@ -86,7 +86,7 @@ if($this->getData(['module', $this->getUrl(0), 'input'])): ?>
|
||||||
]); ?>
|
]); ?>
|
||||||
<?php elseif($input['type'] === $module::TYPE_CHECKBOX):
|
<?php elseif($input['type'] === $module::TYPE_CHECKBOX):
|
||||||
echo template::checkbox('formInput[' . $index . ']', true, $input['name'], [
|
echo template::checkbox('formInput[' . $index . ']', true, $input['name'], [
|
||||||
'checked' => $_SESSION['draft']['checkbox'][$checkboxIndex]
|
'checked' => isset($_SESSION['draft']['checkbox'][$checkboxIndex]) ? $_SESSION['draft']['checkbox'][$checkboxIndex] : false
|
||||||
]);
|
]);
|
||||||
$checkboxIndex++; ?>
|
$checkboxIndex++; ?>
|
||||||
<?php elseif($input['type'] === $module::TYPE_FILE): ?>
|
<?php elseif($input['type'] === $module::TYPE_FILE): ?>
|
||||||
|
|
Loading…
Reference in New Issue