Skip to Content Skip to Menu

🕒 Save Time and Effort with CB Editor Assistant: Effortlessly create and refine content in Joomla 3, 4, & 5.
🎁 Limited Offer: Enjoy a 5-day FREE trial and save up to 30% afterward!

Set a non-editable field if another field has a specific value

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
7 years 10 months ago #292072 by AchLive
I would like to know how to have the Original Field Value in the display condition that I wrote above.
I tried this but it does not work
Code:
[cb:if FIELD_NAME="test"][cb:userfield field="FIELD_NAME" /]<div class="hidden">[value]</div>[/cb:if] [cb:if FIELD_NAME!="test"][value][/cb:if]
It works so well but I have a Simple Raw Field Value
Code:
[cb:if FIELD_NAME="test"][FIELD_NAME]<div class="hidden">[value]</div>[/cb:if] [cb:if FIELD_NAME!="test"][value][/cb:if]
Thank you

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 10 months ago #292082 by krileon

With the Conditional, since I have reset active on settings CB Conditional, the fields would not be visible, but also lose the stored data.
Instead I just want that you can not change the data but which must remain stored on DB.

Then your only option is read only as CB Conditional can not currently disable the reset functionality on a per field basis (this is planned).

I tried this but it does not work

The [cb:userfield field="FIELD_NAME" /] usage checks access permissions and conditions. So if the user can't see the field on their profile then that substitution won't output anything.


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.

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
7 years 10 months ago - 7 years 10 months ago #292086 by AchLive

The [cb:userfield field="FIELD_NAME" /] usage checks access permissions and conditions. So if the user can't see the field on their profile then that substitution won't output anything.


It does not work well only when I insert it in the "if" ie
Code:
[cb:if FIELD_NAME="test"][cb:userfield field="FIELD_NAME" /]<div class="hidden">[value]</div>[/cb:if] [cb:if FIELD_NAME!="test"][value][/cb:if]
but if I write without "If" so
Code:
[cb:userfield field="FIELD_NAME" /]
then it works

I think it depends on my code error.

Alternatively I would like to know if I can use or create a class to make read-only field (always to be included in an if statement)

I want to know how to write correctly
Thank you
Last edit: 7 years 10 months ago by AchLive.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 10 months ago #292102 by krileon

Alternatively I would like to know if I can use or create a class to make read-only field (always to be included in an if statement)

No. A read only field does not submit to the POST. CB will not know it's read only, because you didn't set it read only in CB > Field Management. This means it won't have a value in POST and will null the value for storage. Your only option is as follows as again it is entirely visual as it has no PHP side checks to enforce this. There is no "edit once" field functionality, sorry.

Code:
[cb:if FIELD_NAME!=""]PASS<div class="hidden">[value]</div>[/cb:if] [cb:if FIELD_NAME=""][value][/cb:if]

The above should display PASS and put the input in a hidden div if the field has a value. If it doesn't have a value it should display normally.


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.

  • AchLive
  • AchLive
  • OFFLINE
  • Posts: 253
  • Thanks: 14
  • Karma: 3
7 years 10 months ago #292104 by AchLive
So this may not work?
Code:
[cb:if FIELD_NAME="test"][cb:userfield field="FIELD_NAME" /]<div class="hidden">[value]</div>[/cb:if] [cb:if FIELD_NAME!="test"][value][/cb:if]
As I wrote above, but you have not answered.

Works for me to use the hidden field, with what you suggested, but why does not work if call with?
Code:
[cb:userfield field="FIELD_NAME" /]
instead it works if called with
Code:
[FIELD_NAME]

It does not seem logical. Perhaps it is not correct as I write the code?
Thank you

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 10 months ago #292111 by krileon

So this may not work?

Should work fine assuming the field displays on profile fine for the user editing their profile.

Works for me to use the hidden field, with what you suggested, but why does not work if call with?

Because [cb:userfield field="FIELD_NAME" /] checks access and display permissions. If the field isn't set to display on profile then that substitution won't display anything. If it's conditioned away on profile then it also won't display, etc.. [FIELD_NAME] is a raw value from the user object. It does not check permissions.


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