diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index f630de3f8aa..1786cf8dadb 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -655,15 +655,11 @@ else if ($action == 'add' && $user->rights->facture->creer) $db->begin(); $error=0; - - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=GETPOST($key); - } - } + + // Fill array 'array_options' with data from add form + $extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + // Replacement invoice if ($_POST['type'] == 1) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 9cf992561bf..358201aa4a7 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -75,6 +75,8 @@ if (empty($conf->global->MEMBER_ENABLE_PUBLIC)) exit; } +$extrafields = new ExtraFields($db); + /** * Show header for new member @@ -245,11 +247,10 @@ if ($action == 'add') $adh->morphy = $_POST["morphy"]; $adh->birth = $birthday; - foreach($_POST as $key => $value){ - if (preg_match("/^options_/",$key)){ - $adh->array_options[$key]=$_POST[$key]; - } - } + + // Fill array 'array_options' with data from add form + $extralabels=$extrafields->fetch_name_optionals_label($adh->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels,$adh); $result=$adh->create($user->id); if ($result > 0) @@ -360,7 +361,6 @@ if ($action == 'added') $form = new Form($db); $formcompany = new FormCompany($db); $adht = new AdherentType($db); -$extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label('adherent'); // fetch optionals attributes and labels