replace the value User

  • DAVIDPL
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 68
  • Thank you received: 0

DAVIDPL created the topic: replace the value User

It is possible to replace the value getUser = (888) of the following code, by a variable or by the value of a field in the form.

<?php $user = JFactory::getUser(888); return $user->get('name'); ?>
#240882
  • TheMuffinMan
  • TheMuffinMan's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 8404
  • Karma: 164
  • Thank you received: 669

TheMuffinMan replied the topic: replace the value User

Hi,

since this would be like a default value, rendered upon form display, you can alter it using javascript on the fly using an action script.

For example:

Go to the field's advanced tab -> Action Script that is supposed to change the value of the field above.

Click "Custom" and check "Change"

Click "Create Code Framework"

In the resulting code skeleton, right after "case 'change':", add this:
ff_getElementByName('FIELDNAME').value = element.value;

FIELDNAME, would be the name of the field (not title) that holds your value from above and element.value would just replace its content with the value from the field where the action happens.

This example is for text fields and dropdowns, for other types you need to determine their values based on their types.

Regards,
Markus

===========================
If you are happy, please leave us a small review here to keep us motivated:
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

⭐⭐⭐⭐⭐ BreezingForms: extensions.joomla.org/extension/contacts...orms/breezing-forms/
⭐⭐⭐⭐⭐ ContentBuilder: extensions.joomla.org/extension/authorin...tion/contentbuilder/

===========================
Satisfied?
Get a membership!
===========================
#240929
  • DAVIDPL
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 68
  • Thank you received: 0

DAVIDPL replied the topic: replace the value User

Hello
Maybe it wasn't explained well.

What I am trying is the following:

When I enter the data in the field: A

A = customer code, B = customer name.

Automatically obtain the customer's name in field B on the form.

With the following code in the value field it forces me to make it fixed, but what I want is for it to be variable.

customer: 888
<? php $ user = JFactory :: getUser (888); return $ user-> get ('name'); ?>

client: logeado
<? php $ user = JFactory :: getUser (); return $ user-> get ('name'); ?>
#240954
  • TheMuffinMan
  • TheMuffinMan's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 8404
  • Karma: 164
  • Thank you received: 669

TheMuffinMan replied the topic: replace the value User

You mean you want to pick a certain user and not use the currently logged on user?

===========================
If you are happy, please leave us a small review here to keep us motivated:
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

⭐⭐⭐⭐⭐ BreezingForms: extensions.joomla.org/extension/contacts...orms/breezing-forms/
⭐⭐⭐⭐⭐ ContentBuilder: extensions.joomla.org/extension/authorin...tion/contentbuilder/

===========================
Satisfied?
Get a membership!
===========================
#240994
  • DAVIDPL
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 68
  • Thank you received: 0

DAVIDPL replied the topic: replace the value User

Hi

If right
any user
#240996
  • TheMuffinMan
  • TheMuffinMan's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 8404
  • Karma: 164
  • Thank you received: 669

TheMuffinMan replied the topic: replace the value User

Hi,

please see the form attached.
Download, unzip and install it in BreezingForms => Configuration => Package Installer.

In manage forms, try it out. At least that's how I understood how it should work.

The most important parts in terms of code are located in the actionscript of the search button and in form => advanced => more options => form pieces.

File Attachment:

File Name: usersearch.zip
File Size:10 KB


Regards,
Markus

===========================
If you are happy, please leave us a small review here to keep us motivated:
(Please turn off your VPN and local Apache prior reviewing as your review might get blocked)

⭐⭐⭐⭐⭐ BreezingForms: extensions.joomla.org/extension/contacts...orms/breezing-forms/
⭐⭐⭐⭐⭐ ContentBuilder: extensions.joomla.org/extension/authorin...tion/contentbuilder/

===========================
Satisfied?
Get a membership!
===========================
#241029
Attachments:
Moderators: ForumSupport
Time to create page: 0.051 seconds

We Are Doing Our Part

Massive discounts on all of our extension subscription plans to help you and your business in these times.

Get Your Subscription Here

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

News and Updates

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

All Extensions Subscription

We are doing our part and support your business with extremely low prices -- For example 6-Months-Subscription for only $9 USD. For as long as necessary.

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!