Merging Two Fields in ContentBuilder

  • Posts: 2368
  • Karma: 85
  • Thank you received: 319

mihaela replied the topic: Merging Two Fields in ContentBuilder

Hello,

The script suggested below should concatenate values from fields named field1, field2 and field3:
contentbuilder.onSubmit(
   function(){
       contentbuilder._('allfields').value = contentbuilder._('field1').value + ' ' + contentbuilder._('filed2').value + ' ' + contentbuilder._('filed3').value;
       return true;
   }
);
What is important to note is that the concatenation of the fields is done when submit button is clicked (and not while entering values) and that might be the reason you think it is not working.

Let me know whether you have managed to set this up to work for your view.

Regards,

Mihaela
#234913
  • Posts: 46
  • Thank you received: 0

Bibbp replied the topic: Merging Two Fields in ContentBuilder

Thanks Mihaela, are the field names the names in the view or in the datastore? Secondly, my result field (allfields in your example) is also a database field. If I do not set it as editable the form creates error messages, so I have set it as hidden. Is this correct?
#234914
  • Posts: 2368
  • Karma: 85
  • Thank you received: 319

mihaela replied the topic: Merging Two Fields in ContentBuilder

Hi again,

The field names are the names which you can find in data storage.

As for the result field, you can set this field to hidden and editable and in my opinion it should work.
I have set it to be textfield and marked as "Readonly" in settings of that element and it is working fine for me.

Regards,

Mihaela
#234918
  • Posts: 46
  • Thank you received: 0

Bibbp replied the topic: Merging Two Fields in ContentBuilder

Hi

My code looks right:
contentbuilder.onSubmit(
function(){
contentbuilder._('name').value = contentbuilder._('firstname').value + ' ' + contentbuilder._('lastname').value;
return true;
}
);
it is in the Init(JS) section of the field in the view. The field is defined as text and read-only, and the fields listed above are the fields in the datastore not the view. The merge is not working so can you tell me where I am going wrong?

Secondly, I have put a unique value constraint on the name field in the database, how of I capture the error when a duplicate is being added and display a friendly error message (not a 1062 duplicate error page in the browser)?

Thanks

Peter
#235111
  • Posts: 2368
  • Karma: 85
  • Thank you received: 319

mihaela replied the topic: Merging Two Fields in ContentBuilder

Hello again,

Could you send me backend login info for your view to mihaela.kobovac@crosstec.org so I can test this from first hand?
In the email, please write the name of the View and Data Storage that I should look at.

I've tested your code now in the Init JS section of the field in my view and it is working fine so there must be something that is not set up correctly.

Regards,

Mihaela
#235115
  • Posts: 46
  • Thank you received: 0

Bibbp replied the topic: Merging Two Fields in ContentBuilder

I have provided the info but heard nothing back...
#235296
Moderators: ForumSupporttomeperica
Time to create page: 0.118 seconds

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans & templates!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here