FIX Update form erased extrafields that were hidden
This commit is contained in:
parent
1c19c97cf2
commit
b726e96f4b
@ -182,7 +182,7 @@ if ($action == 'update' && !empty($permissiontoadd))
|
||||
|
||||
// Fill array 'array_options' with data from add form
|
||||
if (!$error) {
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
|
||||
if ($ret < 0) $error++;
|
||||
}
|
||||
|
||||
|
||||
@ -5848,7 +5848,7 @@ abstract class CommonObject
|
||||
* Update an extra field value for the current object.
|
||||
* Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
|
||||
*
|
||||
* @param string $key Key of the extrafield (without starting 'options_')
|
||||
* @param string $key Key of the extrafield to update (without starting 'options_')
|
||||
* @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY)
|
||||
* @param User $userused Object user
|
||||
* @return int -1=error, O=did nothing, 1=OK
|
||||
@ -7159,8 +7159,6 @@ abstract class CommonObject
|
||||
|
||||
$html_id = (empty($this->id) ? '' : 'extrarow-'.$this->element.'_'.$key.'_'.$this->id);
|
||||
|
||||
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
|
||||
|
||||
if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && ($e % 2) == 0) { $colspan = '0'; }
|
||||
|
||||
if ($action == 'selectlines') { $colspan++; }
|
||||
@ -7190,6 +7188,7 @@ abstract class CommonObject
|
||||
$labeltoshow = $langs->trans($label);
|
||||
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);
|
||||
|
||||
$out .= '<tr '.($html_id ? 'id="'.$html_id.'" ' : '').$csstyle.' class="'.$class.$this->element.'_extras_'.$key.' trextrafields_collapse'.$extrafields_collapse_num.'" '.$domData.' >';
|
||||
$out .= '<td class="';
|
||||
//$out .= "titlefield";
|
||||
//if (GETPOST('action', 'none') == 'create') $out.='create';
|
||||
|
||||
@ -2017,7 +2017,9 @@ class ExtraFields
|
||||
*
|
||||
* @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
|
||||
* @param object $object Object
|
||||
* @param string $onlykey Only the following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must set this to avoid to have other extrafields being reset.
|
||||
* @param string $onlykey Only some keys are filled:$this
|
||||
* 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset.
|
||||
* '@GETPOSTISSET' => When we make update of extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset.
|
||||
* @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
|
||||
*/
|
||||
public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
|
||||
@ -2034,7 +2036,8 @@ class ExtraFields
|
||||
// Get extra fields
|
||||
foreach ($extralabels as $key => $value)
|
||||
{
|
||||
if (!empty($onlykey) && $key != $onlykey) continue;
|
||||
if (!empty($onlykey) && $onlykey != '@GETPOSTISSET' && $key != $onlykey) continue;
|
||||
if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && ! GETPOSTISSET('options_'.$key)) continue;
|
||||
|
||||
$key_type = $this->attributes[$object->table_element]['type'][$key];
|
||||
if ($key_type == 'separate') continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user