1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

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

Discussion in 'Community' started by mvilela, Oct 25, 2017.

  1. mvilela

    mvilela Member

    Level: Community
    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.
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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 (Text):

    $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
     
  3. mvilela

    mvilela Member

    Level: Community
    Obviously it works. Thank you
     
  4. mvilela

    mvilela Member

    Level: Community
    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 ?.
     

Share This Page