NEW Support html content for multiselect component.

This commit is contained in:
Laurent Destailleur 2022-02-21 16:54:07 +01:00
parent 00e6d2786d
commit 97ed94fbda
4 changed files with 14 additions and 6 deletions

View File

@ -178,7 +178,9 @@ print '</td></tr>';
// Parent category
print '<tr><td>'.$langs->trans("In").'</td><td>';
print img_picto('', 'category', 'class="pictofixedwidth"');
print $form->select_all_categories($type, $object->fk_parent, 'parent', 64, $object->id);
print ajax_combobox('parent');
print '</td></tr>';
$parameters = array();

View File

@ -8123,12 +8123,9 @@ class Form
$out .= "\n".'<script>'."\n";
if ($addjscombo == 1) {
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out .= 'function formatResult(record) {'."\n";
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
}
$out .= 'function formatResult(record, container) {'."\n";
$out .= ' if ($(record.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(record.element).attr("data-html")); // If property html set, we decode html entities and use this'."\n";
$out .= ' return record.text;';
$out .= '};'."\n";
$out .= 'function formatSelection(record) {'."\n";
if ($elemtype == 'category') {
@ -8150,6 +8147,7 @@ class Form
// Specify format function for dropdown item
formatResult: formatResult,
templateResult: formatResult, /* For 4.0 */
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
// Specify format function for selected item
formatSelection: formatSelection,
templateSelection: formatSelection /* For 4.0 */

View File

@ -6239,6 +6239,10 @@ span#select2-boxbookmark-container {
overflow: hidden;
}
ul.select2-results__options li {
font-size: 0.95em;
}
/* ============================================================================== */
/* For categories */

View File

@ -6117,6 +6117,10 @@ span.select2.select2-container.select2-container--default {
text-align: initial;
}
ul.select2-results__options li {
font-size: 0.95em;
}
/* ============================================================================== */
/* For categories */