Add default values for Create

Added default extrafield values for html and text fields to prepopulate data on record create only.
This commit is contained in:
Matt Sidnell 2020-04-20 22:42:13 +01:00
parent a9558972d9
commit ea9f0097a2

View File

@ -7117,6 +7117,14 @@ abstract class CommonObject
{
$value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key];
}
// HTML and text add default value
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text')))
{
if($action=='create') $value = $extrafields->attributes[$this->table_element]['default'][$key];
else $value = $this->array_options['options_'.$key];
}
$labeltoshow = $langs->trans($label);
$helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]);