diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 4d4c12ce473..cee75415eee 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -141,8 +141,13 @@ if ($action == 'update' && !empty($permissiontoadd)) if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Set value to update - if (in_array($object->fields[$key]['type'], array('text', 'html'))) { - $value = GETPOST($key, 'restricthtml'); + if (preg_match('/^(text|html)/', $object->fields[$key]['type'])) { + $tmparray = explode(':', $object->fields[$key]['type']); + if (!empty($tmparray[1])) { + $value = GETPOST($key, $tmparray[1]); + } else { + $value = GETPOST($key, 'restricthtml'); + } } elseif ($object->fields[$key]['type'] == 'date') { $value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); } elseif ($object->fields[$key]['type'] == 'datetime') { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 384c778d602..46567edf369 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5800,7 +5800,7 @@ abstract class CommonObject } elseif (in_array($type, array('mail', 'phone', 'url'))) { $out = ''; - } elseif ($type == 'text') + } elseif (preg_match('/^text/', $type)) { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { @@ -5810,7 +5810,7 @@ abstract class CommonObject } else { $out = ''; } - } elseif ($type == 'html') + } elseif (preg_match('/^html/', $type)) { if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field { @@ -6584,7 +6584,7 @@ abstract class CommonObject return 'Error bad setup of extrafield'; } } else $value = ''; - } elseif ($type == 'text' || $type == 'html') + } elseif (preg_match('/^(text|html)/', $type)) { $value = dol_htmlentitiesbr($value); } elseif ($type == 'password') diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php index ace640d9b79..ad1a3bd2330 100644 --- a/htdocs/core/tpl/commonfields_edit.tpl.php +++ b/htdocs/core/tpl/commonfields_edit.tpl.php @@ -45,15 +45,23 @@ foreach ($object->fields as $key => $val) print ''; if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help'])); else print $langs->trans($val['label']); print ''; print ''; if (in_array($val['type'], array('int', 'integer'))) $value = GETPOSTISSET($key) ?GETPOST($key, 'int') : $object->$key; - elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key) ?GETPOST($key, 'restricthtml') : $object->$key; - else $value = GETPOSTISSET($key) ?GETPOST($key, 'alpha') : $object->$key; + elseif (preg_match('/^(text|html)/', $val['type'])) { + $tmparray = explode(':', $val['type']); + if (!empty($tmparray[1])) { + $check = $tmparray[1]; + } else { + $check = 'restricthtml'; + } + $value = GETPOSTISSET($key) ? GETPOST($key, $check) : $object->$key; + } + else $value = GETPOSTISSET($key) ? GETPOST($key, 'alpha') : $object->$key; //var_dump($val.' '.$key.' '.$value); if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0); else print $object->showInputField($val, $key, $value, '', '', '', 0); diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 399dd3b10b8..8465f804d5c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -70,7 +70,7 @@ class MyObject extends CommonObject /** - * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * 'label' the translation key. * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)