diff --git a/module/form/form.php b/module/form/form.php index 309eb62..d1df2a6 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -391,6 +391,17 @@ class form extends common { $param = ''; $detectBot =''; 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 if($this->isPost()) { // $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 $textIndex = 0; $selectIndex=0; $checkboxIndex=0; for( $index = 0; $index <= count($this->getData(['module', $this->getUrl(0), 'input'])); $index++){ diff --git a/module/form/view/index/index.php b/module/form/view/index/index.php index e3c8c63..ecbf475 100644 --- a/module/form/view/index/index.php +++ b/module/form/view/index/index.php @@ -60,14 +60,14 @@ if($this->getData(['module', $this->getUrl(0), 'input'])): ?> 'formInput_' . $index, 'label' => $input['name'], - 'selected' => $values[$_SESSION['draft']['select'][$selectIndex]] + 'selected' => isset($_SESSION['draft']['select'][$selectIndex])? $values[$_SESSION['draft']['select'][$selectIndex]] : '' ]); $selectIndex++; ?> 'formInput_' . $index, 'label' => $input['name'], - 'value' => $_SESSION['draft']['text'][$textIndex] + 'value' => isset($_SESSION['draft']['text'][$textIndex]) ? $_SESSION['draft']['text'][$textIndex] : '' ]); $textIndex++; ?> @@ -86,7 +86,7 @@ if($this->getData(['module', $this->getUrl(0), 'input'])): ?> ]); ?> $_SESSION['draft']['checkbox'][$checkboxIndex] + 'checked' => isset($_SESSION['draft']['checkbox'][$checkboxIndex]) ? $_SESSION['draft']['checkbox'][$checkboxIndex] : false ]); $checkboxIndex++; ?>