• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Pre Populated Entries

Pre Populated Entries 2 weeks 4 days ago #43400

  • AlexR
  • AlexR's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
Some time ago I learned about being able to pre-populate field entries, such as name and email using code in the "default value" area.

Example 1, if a user is logged in and I wanted to already have their name appear in the Name field I added this code:

//<code>
$user = JFactory::getUser();
return $user->get('name');
//</code>

Example 2, if a user is logged in and I wanted to already have their email address appear in the Name field I added this code:

//<code>
$user = JFactory::getUser();
return $user->get('email');
//</code>

I have some questions about this ability:

1. The above code was used in Joomla 3.x sites. Will it be different for Joomla 4 sites? If so, what is it?

2. If the site is using Community Builder for user management and I have created custom-field entries for the registration, such as an address, Is there a way to extrapolate that data and also pre-populate the information in an address field in RS Forms?

Thanks in advance!
The administrator has disabled public write access.

Pre Populated Entries 2 weeks 2 days ago #43402

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 216
  • Thank you received: 57
That will work in Joomla 4 as is
In J3 you could prefill form fields using Jfactory https://docs.joomla.org/Selecting_data_using_JDatabase
however in J4 and 5 I believe you need to change
$db = JFactory::getDbo();

to
$db = Factory::getContainer()->get('DatabaseDriver');

from a discussion here https://joomla.stackexchange.com/questions/24484/jfactorygetdbo-deprecated-whats-the-replacement
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!