Skip to Content Skip to Menu

Field label question...

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 391
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 2 months ago - 1 year 11 months ago #330687 by liaskas
Field label question... was created by liaskas
Hello...

we have a a special requirement on a project based on communiity builder.

During registration the user has to select if he is going to register as an individual or as a company (We are using a single radio button for the users to choose). According to the user's selection we show different fields in the registration form using conditionals. So far so good.

The problem is with the "Name field" (we do not use username).

The "Name" field can be used both for...
A ) First and Last name (for individuals registration)
B ) Company name (for companies registration)

Is there a way to have a different field label for each one of the 2 selections so that...

1) when user registers as individual, the label is "First and Last name"
2) when user registers as a company, the label is "Company registration name"

Maybe it can be done by substituting somehow the sting in the language file.

Can you please advise?

Thank you.
Last edit: 1 year 11 months ago by liaskas.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 2 months ago #330702 by krileon
Replied by krileon on topic Field label question...
We don't have any functionality for conditioning labels. Best I can suggest is you'll need to consider implementing that yourself using some custom JavaScript. The below will at least condition it in profile edit and profile view though using IF substitutions in the label.
Code:
[cb:if cb_profiletype="individual"]Name[cb:elseif cb_profiletype="company"]Company[/cb:elseif][cb:else]Name / Company[/cb:else][/cb:if]

In this example if cb_profiletype is set to individual it will display Name. If set to company it will display Company. If not set at all it will display Name / Company.

Again, this won't dynamically update on registration or anything like that. You'd need some custom JavaScript to detect that your radio field has changed then update the label accordingly. You can add your custom JS to CBs registration page using a Code action on the onBeforeRegisterFormDisplay trigger.


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.

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 391
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 2 months ago #330714 by liaskas
Replied by liaskas on topic Field label question...
We need this for registration so substituting for profile view and edit is not what we need.

If we create a new field that will show in registration, is it possible that we can make it fill the "Name" field through an auto action?

example....

field "Company Name" is filled during registration by the user.

Can we set "Name" = "Company Name" through an auto action?

Thank you...

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 2 months ago #330724 by krileon
Replied by krileon on topic Field label question...
Yes that's possible, but you're creating a lot of work for something that would be probably 10 lines of JavaScript. I suggest looking into changing the label based off the radio selection using JavaScript instead. You can add that JS to the registration page using CB Auto Actions and a Code action on the onBeforeRegisterFormDisplay trigger.


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.

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 391
  • Thanks: 36
  • Karma: 2
  • Add-ons
2 years 2 months ago #330731 by liaskas
Replied by liaskas on topic Field label question...
Unfortunately i do not know how to write javascript so i tried the hardway.

Created field "Company Name" ( cb_companyname )

Created auto action...
Global
Triggers: onAfterUserRegistration
Type: Field
User: Automatic
Access: Eveybody

Action
Field: Name
Operator: Set (Field = Value)
Value: [cb_companyname]
Translate Value: No
Save Directly: Yes

but it does not work... all database fields (firstname, midlename, lastname) remain NULL

Any ideas?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 2 months ago #330732 by krileon
Replied by krileon on topic Field label question...
It has to happen super early in the registration process as name is a required field. It's the hard way for good reason. Specifically the onStartSaveUserRegistration trigger has to be used in a Code action to modify the reference user object. Check the below topics as they're examples of using it to set user data early.

www.joomlapolis.com/forum/developer-members-support/244706-generate-usernames#328306
www.joomlapolis.com/forum/developer-members-support/244550-registering-users-without-email#327669

JS would absolutely be the better way to do this and recommend hiring someone to write the JS for you or give learning some JS a try.


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