Page 1 of 1
How to customize color on checkbox items?
Posted: Tue May 23, 2023 4:09 pm
by amiens80
hi,
i tried to search an example in the demo to explain, but i can't find a demo where checkbox are used in the demo.
So i explain :
i have a basic category table:
id, name, color (with color picker extension)
------------------------------
1 red #FF0000
2 black #000000
3 white #FFFFFF
and a basic car table:
id name colors (color is checkbox field):
---------------------------------------
1 volvo 1,2,3
2 ford 1,3
3 lada 2
in my car list, i have a color column which displays multiple values for colors (depending of what is checked in the checkbox).
is there a way to display the category name in color font depending of each one ? i want to write RED in red color font ,BLACK in black, and WHITE in white color font. (like system tag with color)
I know i can use the server script in ListOptions_Rendered to change the color font of each value, but i can't have access of the color field value !
with $this->car_colors->CurrentValue
, i have a value like "1,3" and that does not indicate the color.... so i'm stuck !
so is there a way to perform such colored checkboxes item ?
Re: How to customize color on chechbox items?
Posted: Tue May 23, 2023 4:39 pm
by arbei
Re: How to customize color on chechbox items?
Posted: Tue May 23, 2023 5:21 pm
by amiens80
i just tested it.
it did not workd.
first i tried :
<span class="text-info" style="color:{{:df2}}">{{:df1}}</span>
i see the text color turned to blue for all item
then i tested this (put the value in the tooltip on item)
<span class="text-info" title="{{:df2}}">{{:df1}}</span>
and this second works fine , so i guess the style tag is forbidden in the Option Template ....
Moreover, it works only on edit view (and search view) , not on view list...
in list page, the column items are not colored and the display-field2 are showed...
Re: How to customize color on chechbox items?
Posted: Tue May 23, 2023 5:29 pm
by arbei
Your attributes are wrong. If you use class="text-info"
, the span tag is already colored (see Bootstrap Colors). You should remove it if you want to use style attribite.
Re: How to customize color on chechbox items?
Posted: Tue May 23, 2023 5:39 pm
by amiens80
you are right.
<span style="color:{{:df2}}">{{:df1}}</span>
works (edit view and search view , not in viewlist page) . i did not need "text-info" . i thought it was the default.
Re: How to customize color on checkbox items?
Posted: Tue May 30, 2023 5:52 pm
by amiens80
it is ok, i managed to make it (a system color tag by checkbox options). each record can now be selected with multiple color items, like tags in common CMS content.
Re: How to customize color on checkbox items?
Posted: Tue May 30, 2023 6:43 pm
by arbei
Option Template is designed exactly for users to customize options by own HTML/CSS themselves.