2
0
forked from Wavyzz/dolibarr

NEW Add property cssview when declaring fields of an object

This commit is contained in:
Laurent Destailleur
2020-09-22 08:54:40 +02:00
parent aee6bc173f
commit c61e8f052b
4 changed files with 13 additions and 10 deletions

View File

@@ -5741,11 +5741,9 @@ abstract class CommonObject
}
// Set value of $morecss. For this, we use in priority showsize from parameters, then $val['css'] then autodefine
if (empty($morecss) && !empty($val['css']))
{
if (empty($morecss) && !empty($val['css'])) {
$morecss = $val['css'];
} elseif (empty($morecss))
{
} elseif (empty($morecss)) {
if ($type == 'date')
{
$morecss = 'minwidth100imp';
@@ -5792,16 +5790,16 @@ abstract class CommonObject
{
$tmp = explode(',', $size);
$newsize = $tmp[0];
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif (in_array($type, array('real')))
{
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif (preg_match('/varchar/', $type))
{
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$size.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif (in_array($type, array('mail', 'phone', 'url')))
{
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
} elseif ($type == 'text')
{
if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field

View File

@@ -59,6 +59,7 @@ foreach ($object->fields as $key => $val)
print '</td>';
print '<td class="valuefield fieldname_'.$key;
if ($val['type'] == 'text') print ' wordbreak';
if ($val['cssview']) print ' '.$val['cssview'];
print '">';
if (in_array($val['type'], array('text', 'html'))) print '<div class="longmessagecut">';
print $object->showOutputField($val, $key, $value, '', '', '', 0);
@@ -105,7 +106,10 @@ foreach ($object->fields as $key => $val)
if (!empty($val['help'])) print $form->textwithpicto($langs->trans($val['label']), $langs->trans($val['help']));
else print $langs->trans($val['label']);
print '</td>';
print '<td>';
print '<td class="valuefield fieldname_'.$key;
if ($val['type'] == 'text') print ' wordbreak';
if ($val['cssview']) print ' '.$val['cssview'];
print '">';
if (in_array($val['type'], array('text', 'html'))) print '<div class="longmessagecut">';
print $object->showOutputField($val, $key, $value, '', '', '', 0);
//print dol_escape_htmltag($object->$key, 1, 1);

View File

@@ -83,7 +83,7 @@ class MyObject extends CommonObject
* 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
* 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
* 'css' is the CSS style to use on field. For example: 'maxwidth200'
* 'css' and 'cssview' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. For example: 'maxwidth200', 'wordbreak'
* 'help' is a string visible as a tooltip on field
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.

View File

@@ -3207,6 +3207,7 @@ div.refid {
font-weight: bold;
color: var(--colortexttitlenotab);
font-size: 1.2em;
word-break: break-word;
}
div.refidno {
padding-top: 3px;