Merge pull request #13491 from atm-lena/11.0_FIX_Ticket_ExtrafieldsVisibility_4

FIX 11.0 Ticket - Visibility 4, don't display extrafields at the creation
This commit is contained in:
Laurent Destailleur 2020-04-05 02:54:41 +02:00 committed by GitHub
commit 22a8c207f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 9 deletions

View File

@ -6635,7 +6635,8 @@ abstract class CommonObject
$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1);
}
if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
elseif (($mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3 && abs($visibility) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list and <> 4 = not visible at the creation
elseif ($mode == 'view' && empty($visibility)) continue;
if (empty($perms)) continue;
// Load language if required
@ -6663,9 +6664,11 @@ abstract class CommonObject
case "view":
$value = $this->array_options["options_".$key.$keysuffix];
break;
case "edit":
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
case "create":
case "edit":
$getposttemp = GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none'); // GETPOST can get value from GET, POST or setup of default values.
// GETPOST("options_" . $key) can be 'abc' or array(0=>'abc')
if (is_array($getposttemp) || $getposttemp != '' || GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix))
{
if (is_array($getposttemp)) {
@ -6769,7 +6772,8 @@ abstract class CommonObject
case "view":
$out .= $extrafields->showOutputField($key, $value);
break;
case "edit":
case "create":
case "edit":
$out .= $extrafields->showInputField($key, $value, '', $keysuffix, '', 0, $this->id, $this->table_element);
break;
}

View File

@ -127,7 +127,7 @@ class FormTicket
* @param int $withdolfichehead With dol_fiche_head
* @return void
*/
public function showForm($withdolfichehead = 0)
public function showForm($withdolfichehead = 0, $mode = 'edit')
{
global $conf, $langs, $user, $hookmanager;
@ -414,7 +414,7 @@ class FormTicket
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $ticketstat, $this->action); // Note that $action and $object may have been modified by hook
if (empty($reshook))
{
print $ticketstat->showOptionals($extrafields, 'edit');
print $ticketstat->showOptionals($extrafields, 'create');
}
print '</table>';

View File

@ -73,7 +73,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
//print $key.'-'.$enabled.'-'.$perms.'-'.$label.$_POST["options_" . $key].'<br>'."\n";
if (empty($enabled)) continue; // 0 = Never visible field
if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list
if (abs($enabled) != 1 && abs($enabled) != 3 && abs($enabled) != 5 && abs($enabled) != 4) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list <> 4 = not visible at the creation
if (empty($perms)) continue; // 0 = Not visible
// Load language if required

View File

@ -637,7 +637,7 @@ if ($action == 'create' || $action == 'presend')
$defaultref = '';
}
$formticket->showForm(1);
$formticket->showForm(1, 'create');
}
if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'