From bd4e62a5e786d57bb5b5109247d5dbfbe4976502 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 30 Mar 2013 16:58:49 +0100 Subject: [PATCH 1/8] Implement extrafields : calendar on date type and new separator type --- htdocs/product/fiche.php | 109 +++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 1ccc7e2c8b3..80a93028a05 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -56,6 +56,9 @@ if (! empty($user->societe_id)) $socid=$user->societe_id; $object = new Product($db); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('product'); + if ($id > 0 || ! empty($ref)) { $object = new Product($db); @@ -212,14 +215,8 @@ if (empty($reshook)) } } - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=$_POST[$key]; - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); $id = $object->create($user); @@ -272,14 +269,8 @@ if (empty($reshook)) $object->finished = GETPOST('finished'); $object->hidden = GETPOST('hidden')=='yes'?1:0; - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=$_POST[$key]; - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($object->check()) { @@ -632,9 +623,6 @@ if (GETPOST("cancel") == $langs->trans("Cancel")) * View */ -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('product'); - $helpurl=''; if (GETPOST("type") == '0') $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; if (GETPOST("type") == '1') $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; @@ -792,15 +780,29 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(GETPOST('options_'.$key)?GETPOST('options_'.$key):$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + // Show separator only + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + // Convert date into timestamp format + if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + { + $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; + } + + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } } // Note (private, no output on invoices, propales...) @@ -1000,14 +1002,28 @@ else if (empty($reshook) && ! empty($extrafields->attribute_label)) { foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + // Show separator only + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + // Convert date into timestamp format + if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + { + $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; + } + + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''; + print $extrafields->showInputField($key,$value); + print ''."\n"; + } + } } // Note @@ -1230,13 +1246,26 @@ else $parameters=array('colspan' => ' colspan="'.(2+(($showphoto||$showbarcode)?1:0)).'"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) - { + { foreach($extrafields->attribute_label as $key=>$label) { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print ''.$label.''; - print $extrafields->showOutputField($key,$value); - print ''."\n"; + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + // Convert date into timestamp format + if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + { + $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; + } + print ''.$label.''; + print $extrafields->showOutputField($key,$value); + print ''."\n"; + } } } From 3fe1b261368f30c674045155fd02f4d7cbb28f94 Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 30 Mar 2013 17:43:21 +0100 Subject: [PATCH 2/8] New method to CommonObject to display extrafields data output Try for product --- htdocs/core/class/commonobject.class.php | 38 ++++++++++++++++++++++++ htdocs/product/fiche.php | 21 +------------ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b128455b8ff..af5122adbc3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2189,6 +2189,44 @@ abstract class CommonObject } else return 0; } + + /** + * Function to show lines of extrafields with output datas + * + * @param object $extrafields extrafield Object + * + * return string + */ + function showOptionals($extrafields) + { + global $_POST; + + $out = ''; + + if (! empty($this->array_options)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); + if ($extrafields->attribute_type[$key] == 'separate') + { + $out = $extrafields->showSeparator($key); + } + else + { + // Convert date into timestamp format + if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + { + $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key]; + } + $out .= ''.$label.''; + $out .= $extrafields->showOutputField($key,$value); + $out .= ''."\n"; + } + } + } + return $out; + } /** diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 80a93028a05..98a6c35aa09 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -1247,26 +1247,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) - { - $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; - } - print ''.$label.''; - print $extrafields->showOutputField($key,$value); - print ''."\n"; - } - } + print $object->showOptionals($extrafields); } // Note From 1ab1d74c77b10af35f191b61a7bf25ac245b770f Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 30 Mar 2013 17:52:59 +0100 Subject: [PATCH 3/8] New option (MAIN_EXTRAFIELDS_USE_TWO_COLUMS) to split extrafields display into 2 columns --- htdocs/core/class/commonobject.class.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index af5122adbc3..f9a1bad9ef7 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2205,8 +2205,10 @@ abstract class CommonObject if (! empty($this->array_options)) { + $e = 0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); if ($extrafields->attribute_type[$key] == 'separate') { @@ -2214,14 +2216,28 @@ abstract class CommonObject } else { + if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) + { + $out .= ''; + $colspan='0'; + } + else + { + $out .= ''; + } // Convert date into timestamp format if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) { $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key]; } - $out .= ''.$label.''; + $out .= ''.$label.''; + $out .=''; $out .= $extrafields->showOutputField($key,$value); - $out .= ''."\n"; + $out .= ''."\n"; + + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; + else $out .= ''; + $e++; } } } From 2b587e1742fbdf7baabbac86882361a00002c3af Mon Sep 17 00:00:00 2001 From: jfefe Date: Sat, 30 Mar 2013 18:54:51 +0100 Subject: [PATCH 4/8] For thirdparty use new method to display extrafield values --- htdocs/societe/soc.php | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 0972d93f26a..5b3106afa0d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -1761,31 +1761,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - $e=0; - foreach($extrafields->attribute_label as $key=>$label) - { - $colspan='3'; - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - if (($e % 2) == 0) - { - print ''; - $colspan='0'; - } - print ''.$label.''; - print ''; - print $extrafields->showOutputField($key,$value); - print ""; - - if (($e % 2) == 1) print ''; - $e++; - } - } + print $object->showOptionals($extrafields); } // Ban From 6e66922a6b5b0e1f865124f2a332be7d74d4e29c Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 1 Apr 2013 18:46:53 +0200 Subject: [PATCH 5/8] Fix : in extrafield force output for date selector --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f9398c21cb8..5491c727ad6 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -624,7 +624,7 @@ class ExtraFields $formstat = new Form($db); $showtime = in_array($type,array('datetime')) ? 1 : 0; - $out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 0, 0, 1); + $out = $formstat->select_date($value, 'options_'.$key, $showtime, $showtime, $required, '', 1, 1, 1, 0, 1); //$out=''; } elseif (in_array($type,array('int','double'))) From ec52f54a522a0a6291f137d657c925c041271f17 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 1 Apr 2013 18:59:05 +0200 Subject: [PATCH 6/8] Unique function to show input or output of extrafields datas --- htdocs/core/class/commonobject.class.php | 104 +++++++++++++---------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f9a1bad9ef7..43fb4234558 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2190,59 +2190,75 @@ abstract class CommonObject else return 0; } - /** + /** * Function to show lines of extrafields with output datas * * @param object $extrafields extrafield Object + * @param string $mode Show output (view) or input (edit) for extrafield * * return string */ - function showOptionals($extrafields) + function showOptionals($extrafields,$mode='view') { - global $_POST; + global $_POST; - $out = ''; + $out = ''; - if (! empty($this->array_options)) - { - $e = 0; - foreach($extrafields->attribute_label as $key=>$label) - { - $colspan='3'; - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); - if ($extrafields->attribute_type[$key] == 'separate') - { - $out = $extrafields->showSeparator($key); - } - else - { - if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) - { - $out .= ''; - $colspan='0'; - } - else - { - $out .= ''; - } - // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) - { - $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key]; - } - $out .= ''.$label.''; - $out .=''; - $out .= $extrafields->showOutputField($key,$value); - $out .= ''."\n"; - - if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; - else $out .= ''; - $e++; - } - } - } - return $out; - } + if(count($extrafields->attribute_label) > 0) + { + $out .= "\n"; + $out .= ' '; + $out .= "\n"; + + $e = 0; + foreach($extrafields->attribute_label as $key=>$label) + { + $colspan='3'; + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$this->array_options["options_".$key]); + if ($extrafields->attribute_type[$key] == 'separate') + { + $out .= $extrafields->showSeparator($key); + } + else + { + if ( !empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) + { + $out .= ''; + $colspan='0'; + } + else + { + $out .= ''; + } + // Convert date into timestamp format + if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) + { + $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->array_options['options_'.$key]; + } + $out .= ''.$label.''; + $out .=''; + + switch($mode) { + case "view": + $out .= $extrafields->showOutputField($key,$value); + break; + case "edit": + $out .= $extrafields->showInputField($key,$value); + break; + } + + $out .= ''."\n"; + + if (! empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) $out .= ''; + else $out .= ''; + $e++; + } + } + $out .= "\n"; + $out .= ' '; + } + return $out; + } /** From 7ca7c552c06b87410a9857fe28c0944bdf7c7ea3 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 1 Apr 2013 18:59:41 +0200 Subject: [PATCH 7/8] Use new function to show extrafields on products --- htdocs/product/fiche.php | 50 +++------------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 98a6c35aa09..e222476ac1e 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -779,30 +779,8 @@ else $parameters=array('colspan' => ' colspan="2"'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - // Show separator only - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) - { - $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; - } - - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } - } + { + print $object->showOptionals($extrafields,'edit'); } // Note (private, no output on invoices, propales...) @@ -1001,29 +979,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - // Show separator only - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) - { - $value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$object->array_options['options_'.$key]; - } - - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } - } + print $object->showOptionals($extrafields,'edit'); } // Note From a8874ebcc8eeb6bce82d64f044a231cafd732723 Mon Sep 17 00:00:00 2001 From: jfefe Date: Mon, 1 Apr 2013 19:43:26 +0200 Subject: [PATCH 8/8] Uniformize usage of extrafields methods --- htdocs/adherents/fiche.php | 54 +++++-------------------- htdocs/adherents/type.php | 58 ++++++--------------------- htdocs/comm/action/fiche.php | 58 ++++++--------------------- htdocs/comm/mailing/fiche.php | 35 +++-------------- htdocs/comm/propal.php | 21 +--------- htdocs/commande/fiche.php | 20 +--------- htdocs/compta/facture.php | 18 +-------- htdocs/contact/fiche.php | 74 +++++------------------------------ htdocs/societe/soc.php | 67 +------------------------------ htdocs/user/fiche.php | 50 ++++------------------- 10 files changed, 66 insertions(+), 389 deletions(-) diff --git a/htdocs/adherents/fiche.php b/htdocs/adherents/fiche.php index 787cad2664f..e76d41a6fd2 100644 --- a/htdocs/adherents/fiche.php +++ b/htdocs/adherents/fiche.php @@ -64,6 +64,9 @@ if (! empty($conf->mailmanspip->enabled)) $object = new Adherent($db); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('member'); + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($socid); $canvas = $object->canvas?$object->canvas:GETPOST("canvas"); @@ -282,14 +285,8 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer) $object->statut = $_POST["statut"]; $object->public = $_POST["public"]; - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=$_POST[$key]; - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); // Check if we need to also synchronize user information $nosyncuser=0; @@ -451,14 +448,8 @@ if ($action == 'add' && $user->rights->adherent->creer) $object->fk_soc = $socid; $object->public = $public; - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=$_POST[$key]; - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); // Check parameters if (empty($morphy) || $morphy == "-1") { @@ -684,9 +675,6 @@ if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm $form = new Form($db); $formcompany = new FormCompany($db); -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('member'); - $help_url='EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; llxHeader('',$langs->trans("Member"),$help_url); @@ -885,15 +873,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } /* @@ -1128,15 +1108,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } // Third party Dolibarr @@ -1458,13 +1430,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=$object->array_options["options_$key"]; - print "".$label.""; - print $extrafields->showOutputField($key,$value); - print "\n"; - } + print $object->showOptionals($extrafields); } // Third party Dolibarr diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f4a60f55cd9..72fc3cc2a37 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -56,6 +56,9 @@ $result=restrictedArea($user,'adherent',$rowid,'adherent_type'); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); + if (GETPOST('button_removefilter')) { $search_lastname=""; @@ -84,14 +87,8 @@ if ($action == 'add' && $user->rights->adherent->configurer) $adht->mail_valid = trim($_POST["mail_valid"]); $adht->vote = trim($_POST["vote"]); - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $adht->array_options[$key]=GETPOST($key); - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$adht); if ($adht->libelle) { @@ -127,14 +124,8 @@ if ($action == 'update' && $user->rights->adherent->configurer) $adht->mail_valid = trim($_POST["mail_valid"]); $adht->vote = trim($_POST["vote"]); - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $adht->array_options[$key]=GETPOST($key); - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$adht); $adht->update($user->id); @@ -167,8 +158,6 @@ llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_ $form=new Form($db); -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('adherent_type'); // Liste of members type @@ -245,6 +234,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') if ($action == 'create') { $form = new Form($db); + $adht = new AdherentType($db); print_fiche_titre($langs->trans("NewMemberType")); @@ -278,23 +268,11 @@ if ($action == 'create') // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook - - print "\n"; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print '

'; - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$act->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print ' width="30%">'.$label.''."\n"; - } - print '
'; - print $extrafields->showInputField($key,$value); - print '


'; + print $adht->showOptionals($extrafields,'edit'); } + print "\n"; print '
'; print '
    '; @@ -356,23 +334,13 @@ if ($rowid > 0) // Other attributes $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook - - print ''; - - //Extra field if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print '

'; - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($adht->array_options['options_'.$key])?$adht->array_options['options_'.$key]:'')); - print '\n"; - } - print '
'.$label.''; - print $extrafields->showOutputField($key,$value); - print "


'; + // View extrafields + print $adht->showOptionals($extrafields); } + print ''; print ''; /* diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 07a6647f4bb..2851e55dfd9 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -63,6 +63,9 @@ $actioncomm = new ActionComm($db); $contact = new Contact($db); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('actioncomm'); + //var_dump($_POST); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array @@ -203,14 +206,8 @@ if ($action == 'add_action') $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")).'
'; } - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $actioncomm->array_options[$key]=GETPOST($key); - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$actioncomm); if (! $error) { @@ -343,14 +340,8 @@ if ($action == 'update') } $actioncomm->userdone = $userdone; - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $actioncomm->array_options[$key]=GETPOST($key); - } - } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$actioncomm); if (! $error) { @@ -395,9 +386,6 @@ llxHeader('',$langs->trans("Agenda"),$help_url); $form = new Form($db); $htmlactions = new FormActions($db); -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('actioncomm'); - if ($action == 'create') { $contact = new Contact($db); @@ -603,22 +591,13 @@ if ($action == 'create') $parameters=array(); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$actioncomm,$action); // Note that $action and $object may have been modified by hook - print ''; if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print '

'; - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($actioncomm->array_options["options_".$key])?$actioncomm->array_options["options_".$key]:'')); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print ' width="30%">'.$label.''."\n"; - } - print '
'; - print $extrafields->showInputField($key,$value); - print '

'; + print $actioncomm->showOptionals($extrafields,'edit'); } + + print ''; print '

'; print ''; @@ -838,24 +817,13 @@ if ($id > 0) // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$act,$action); // Note that $action and $object may have been modified by hook - - print ''; - if (empty($reshook) && ! empty($extrafields->attribute_label)) { - print '

'; - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$act->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print ' width="30%">'.$label.''."\n"; - } - print '
'; - print $extrafields->showInputField($key,$value); - print '


'; + print $actioncomm->showOptionals($extrafields,'edit'); + } + print ''; print '

'; print '     '; diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index d04b9c7aefe..195db2d53a8 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -48,6 +48,9 @@ $result=$object->fetch($id); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('mailing'); + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('mailingcard')); @@ -631,8 +634,6 @@ if (! empty($_POST["cancel"])) * View */ -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('mailing'); $help_url='EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; llxHeader('',$langs->trans("Mailing"),$help_url); @@ -661,15 +662,7 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } print ''; @@ -823,15 +816,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print "\n"; - } + print $object->showOptionals($extrafields); } print ''; @@ -1072,15 +1057,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print "\n"; - } + print $object->showOptionals($extrafields,'edit'); } print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 7cf90691655..8c51c4ff941 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1347,24 +1347,7 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - - // Show separator only - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } - } + print $object->showOptionals($extrafields,'edit'); } print ""; @@ -1849,7 +1832,7 @@ else print ''; } - + // TODO : use showOptionals($extrafields) function foreach($extrafields->attribute_label as $key=>$label) { $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index bdd61a6ace3..116fd5fe3cb 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1564,15 +1564,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } // Template to use by default @@ -2091,15 +2083,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } // Total HT diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 935d475bb9e..c24f09f4baa 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2097,23 +2097,7 @@ if ($action == 'create') $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - // Show separator only - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } - } + print $object->showOptionals($extrafields,'edit'); } // Modele PDF diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 885711bb526..db0fe091cd9 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -50,6 +50,9 @@ if ($user->societe_id) $socid=$user->societe_id; $object = new Contact($db); $extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('contact'); + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); $objcanvas=null; @@ -155,14 +158,8 @@ if (empty($reshook)) $object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]); $object->birthday_alert = $_POST["birthday_alert"]; - // 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 + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if (! $_POST["lastname"]) { @@ -252,14 +249,8 @@ if (empty($reshook)) $object->priv = $_POST["priv"]; $object->note = $_POST["note"]; - // 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 + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); $result = $object->update($_POST["contactid"], $user); @@ -283,8 +274,6 @@ if (empty($reshook)) * View */ -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('contact'); $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ContactsAddresses"),$help_url); @@ -518,22 +507,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } - } + print $object->showOptionals($extrafields,'edit'); } print "
"; @@ -740,22 +714,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print "\n"; - } - } + print $object->showOptionals($extrafields,'edit'); } $object->load_ref_elements(); @@ -959,20 +918,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print ''.$label.''; - print $extrafields->showOutputField($key,$value); - print "\n"; - } - } + print $object->showOptionals($extrafields); } $object->load_ref_elements(); diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 5b3106afa0d..17892d4631d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -974,40 +974,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - $e=0; - foreach($extrafields->attribute_label as $key=>$label) - { - $colspan='3'; - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - if (($e % 2) == 0) - { - print ''; - $colspan='0'; - } - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print ''; - - // Convert date into timestamp format - if (in_array($extrafields->attribute_type[$key],array('date','datetime'))) - { - $value = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]); - } - - print $extrafields->showInputField($key,$value); - print ''; - - if (($e % 2) == 1) print ''."\n"; - $e++; - } - } + print $object->showOptionals($extrafields,'edit'); } // Ajout du logo @@ -1416,37 +1383,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - $old_pos=0; - $e=0; - foreach($extrafields->attribute_label as $key=>$label) - { - $colspan = '3'; - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - if (($e % 2) == 0) - { - print ''."\n"; - $colspan = '0'; - } - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; - print ''; - print $extrafields->showInputField($key,$value); - print ""."\n"; - - if (($e % 2) == 1 ) - { - print "\n"; - } - $e++; - } - } + print $object->showOptionals($extrafields,'edit'); } // Logo print ''; diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 1ef52efc85b..be62afba37f 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -187,14 +187,8 @@ if ($action == 'add' && $canadduser) $object->note = GETPOST("note"); $object->ldap_sid = GETPOST("ldap_sid"); - // 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 + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); // If multicompany is off, admin users must all be on entity 0. if (! empty($conf->multicompany->enabled)) @@ -329,14 +323,8 @@ if ($action == 'update' && ! $_POST["cancel"]) $object->openid = GETPOST("openid"); $object->fk_user = GETPOST("fk_user")>0?GETPOST("fk_user"):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 + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if (! empty($conf->multicompany->enabled)) { @@ -927,15 +915,7 @@ if (($action == 'create') || ($action == 'adduserldap')) $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } print "\n"; @@ -1304,15 +1284,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showOutputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields); } print "\n"; @@ -1921,15 +1893,7 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - print $extrafields->showInputField($key,$value); - print ''."\n"; - } + print $object->showOptionals($extrafields,'edit'); } print '';