Database Join where the default value is the one already indicated in other form

mvilela

Member
On the page of my club we use the Fabrik for the management of the sports events that we organize. We will use the form "aaa_user" where users register and the form "aaa_prova" for registration in the competitions. In the form "aaa_user" we use the field "team" (database join - table teams) for team registration. In the "aaa_prova" form, I would like to use the "team" field ("database join - table teams") where the default value is the one already indicated in the form "aaa_user". As my computer skills are reduced, I would appreciate it if someone gave me a hand.
 
Assuming you have an element on the aaa_user form that stores the logged on user ID of the person submitting the form, and there is only one row in aaa_user for each user, you should be able to do it with an eval'ed default on the 'team' element in aaa_prova:

Set "Eval" to Yes. In the default, put:

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('team')->from('aaa_user')->where('userid = ' . JFactory::getUser()->get('id'));
$myDb->setQuery($myQuery);
return $myDb->loadResult();

Replace the field and table names as appropriate.

-- hugh
 
some time ago you helped me with this script. It just so happens that it only works for new registrations. If you edit a record where the "team" field is blank, it is not updated. Is another help possible ?.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top