Skip to Content Skip to Menu

Help formatting an ajax field output

2 years 2 weeks ago - 2 years 2 weeks ago #331428 by sbramall77
Hi
I wonder if I could have some help please.
I have a field (radio button) 'cb_25thoct' which exposes 2 values (Yes/No)  via the Core Fields Ajax for front end editing and it works perfectly.
I am very happy with this but I wondered if it were possible to have this conditionally formatted so for example, 'Yes' is displayed as Green whilst 'No' is displayed as Red.
The context is an attendence list for a choir rehearsal schedule so my list will have multiple narrow date fields and a green/red format would help the admins.
I have done an override on the cbAjaxValue as
.cbAjaxValue { flex-grow: 1;color: green;background-color: white;}
but of course this is not conditional.
any help would be very welcome.

Thanks
Steve
Last edit: 2 years 2 weeks ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 2 weeks ago #331432 by krileon
Replied by krileon on topic Help formatting an ajax field output
Edit your field then under Parameters > Layouts try the following.

Profile Value Layout:
Code:
<span class="[cb:if FIELD_NAME_HERE="1"]text-success[cb:else]text-danger[/cb:else][/cb:if]">[value]</span>

Replace FIELD_NAME_HERE with the name of your field that's being edited. This assumes your field uses the value of 1 for Yes and the value of 0 for No. If it doesn't adjust the "1" to "YES_VALUE_HERE" as needed.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

2 years 2 weeks ago #331435 by sbramall77
Replied by sbramall77 on topic Help formatting an ajax field output
Hi Kyle
Thanks very much for the particularly swift responce.
I tried your suggestion and  it works perfectly in my Userlist value area which is exactly what I wanted.
Brilliant support, well done!
I'm glad I came here.
Thanks very much again

Steve

Please Log in or Create an account to join the conversation.

2 years 2 weeks ago #331436 by sbramall77
Replied by sbramall77 on topic Help formatting an ajax field output
also, with another slight tweek

<span class="[cb:if myFieldNamet="1"]p-2 mb-2 bg-success text-white[cb:else]p-2 mb-2 bg-danger text-white[/cb:else][/cb:if]">[value]</span>

I now have exactly what I wanted.

Thanks again

Steve
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

2 years 2 weeks ago #331438 by sbramall77
Replied by sbramall77 on topic Help formatting an ajax field output
Hi again Kyle
Is it possible to do a nested if on this?
So, If Yes, elseif, no, else X

or similar

Thanks Steve

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 2 weeks ago #331440 by krileon
Replied by krileon on topic Help formatting an ajax field output
Yes, using elseif you can have multiple cases. IF substitution examples can be found at the bottom of our substitution tutorial below.

www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum