From ea9f0097a284277122ca71715e02187a9e6f03b5 Mon Sep 17 00:00:00 2001 From: Matt Sidnell <54064522+pstructures@users.noreply.github.com> Date: Mon, 20 Apr 2020 22:42:13 +0100 Subject: [PATCH] Add default values for Create Added default extrafield values for html and text fields to prepopulate data on record create only. --- htdocs/core/class/commonobject.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b94f87c65f..f881a89c204 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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]);