Skip to Content Skip to Menu

Field label question...

  • liaskas
  • liaskas
  • ONLINE
  • Posts: 391
  • Thanks: 36
  • Karma: 2
  • Add-ons
1 year 11 months ago #331763 by liaskas
Replied by liaskas on topic [CLOSED] Field label question...
I am sorry for bringing this topic back again but i have some issues and some advise would be nice.

After i submitted a request for the business membership and did not receive a reply for a few days, i wrote a javascript in components/com_comprofiler/plugin/templates/default/default.php

The script is the following (in case someone needs something like this...

Changed default.php
from...
Code:
    protected function _renderdivs( )     {         $return            =    $this->_renderRegistrationHead()                         .            '<div id="registrationTable" class="cbRegistrationDiv">'                         .                $this->tabContent                         .                '<div class="row no-gutters cbRegistrationButtons">'                         .                    '<div class="offset-sm-3 col-sm-9">'                         .                        '<input type="submit" value="' . $this->registerButton . '" class="btn btn-primary btn-sm-block cbRegistrationSubmit"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'                         .                    '</div>'                         .                '</div>'                         .    $this->_renderRegistrationFooter();         echo $return;     }

to...
Code:
    protected function _renderdivs( )     {         $return            =    $this->_renderRegistrationHead()                         .            '<div id="registrationTable" class="cbRegistrationDiv">'                         .                $this->tabContent                         .                '<div class="row no-gutters cbRegistrationButtons">'                         .                    '<div class="offset-sm-3 col-sm-9">'                         .                        '<input type="submit" value="' . $this->registerButton . '" class="btn btn-primary btn-sm-block cbRegistrationSubmit"' . cbValidator::getSubmitBtnHtmlAttributes() . ' />'                         .                    '</div>'                         .                '</div>'                         .            '</div><script> $(function() {    $(\'input[name="cb_registeras"]\').on(\'click\', function() { var btnname= $(this).val(); if(btnname=="Person"){$("#cblabname").html(\'First and Last name\');}else{$("#cblabname").html(\'Company Name\');} });});</script>'                         .    $this->_renderRegistrationFooter();         echo $return;     }

This worked fine till i had to condition the _UE_NAME in the language file, so that in reason = "edit" and reason = "search" gives me the required label.

I have tried many different conditions and always the result is the same...

When we use if conditions to substitute the label in the language file, we get a blank label in registration form, and the label shows fine on the rest of the site.

Do not know if the script has a problem or if the script does not work if we have conditions in the language file string.

Can you please advise?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
1 year 11 months ago #331777 by krileon
Replied by krileon on topic [CLOSED] Field label question...

After i submitted a request for the business membership and did not receive a reply for a few days

I apologize for the delay. We're seeing pretty high volume of requests and looks like yours slipped through. We're working our way through those we missed.

The script is the following (in case someone needs something like this...

I do not recommend modifying core code. If I recall correctly you just want to conditionally change the label of a field during registration based off another fields value?


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
1 year 11 months ago - 1 year 11 months ago #331780 by liaskas
Replied by liaskas on topic Field label question...
Thank you for your reply Krileon.
We are on the same side regarding the modification of core code.
The first thing we tried was to use the javascript through cb_content module but it did not work. Having in mind your prompt...

Best I can suggest is you'll need to consider implementing that yourself using some custom JavaScript.

we used the javascript in components/com_comprofiler/plugin/templates/default/default.php.

Yes you are right! What we need is to conditionally change the label of a field during registration based off another fields value in registration page, but also be able to conditionally change the label on other pages like profile, edit,  search.

The problem here is that we can only have the one or the other.

If the javascript could be used in a cb_content module (maybe it can and we are doing it the wrong way), then probably we could set the module to show only on registration page and keep all the other pages as they are by default.
 
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
1 year 11 months ago #331785 by krileon
Replied by krileon on topic Field label question...
You don't need to modify the core to insert JS to the registration page. You can do this using CB Auto Actions on the onBeforeRegisterFormDisplay trigger. Example as follows.

Global
Triggers: onBeforeRegisterFormDisplay
Type: Code
User: Automatic
Access: Everybody
Action
Method: jQuery
Code:
Code:
$( '#FIELD_NAME_1' ).on( 'change', function() {     if ( $( this ).val() === 'company' ) {         $( '#cblabFIELD_NAME_2' ).html( 'Company' );     } else {         $( '#cblabFIELD_NAME_2' ).html( 'Name' );     } });

With this example FIELD_NAME_1 should be set to the name of your select field where you select your profile type. It should have at least 1 available option with a value of "company". You can of course modify all this as needed though. FIELD_NAME_2 should be set to the name of the field where you want the label to change. This should probably be used in combination with the substitution usage in the fields label shown in my below reply.

www.joomlapolis.com/forum/professional-members-support/245189-field-label-question?start=0#330702


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
1 year 11 months ago - 1 year 11 months ago #331795 by liaskas
Replied by liaskas on topic Field label question...
Unfortunately it is not working

1. Field that controls the label change

"cb_registeras" with the following values:
    Person (Same as option Label)
    Company (Same as option Label)
    
2. Field who's label changes

"name" (Title _UE_NAME = 'Name' in language file for the moment)

Auto Action that handles the change as it is right now...

Global
Triggers: onBeforeRegisterFormDisplay
Type: Code
User: Automatic
Access: Everybody
Action
Method: jQuery

Code:
Code:
$( '#cb_registeras' ).on( 'change', function() {     if ( $( this ).val() === 'Company' ) {         $( '#cblabname' ).html( 'Company Name' );     } else {         $( '#cblabname' ).html( 'First and Last name' );     } });

Result:
The code exists in the page source but it does nothing.

The Label always shows Name, no matter what the selection of cb_registeras is. And again... if we condition _UE_NAME in the language file, the label dissapears on registration page.

What am i doing wrong?
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
1 year 11 months ago #331801 by krileon
Replied by krileon on topic Field label question...
PM me a link to your registration page and will take a look. You could have other JS errors on the page preventing that JS from working.


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