• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

(SOLVED )Populate Field element after Databasejoin Selected

jmoises

Active Member
Hi, so i seach on the forum and didnt find something similar,

I was using a CALC element and with Ajax calculation = TRUE, and some PHP code to retrive data from a table, depending the databasejoin element selection, was working fine, but CALC element dosent allow to edit the data, so i change the CALC element to a FIELD element and using eval = true and the php code, but my problem is that FIELD elelemt is not AJAX ready so if the user change the Databasejoin the FIELD element is not read again the php code ....

I hope somebody can give me the aproch or advise how can i do this.

Thank you
 
You can use the same approach as in your other just recently solved thread.

In databasejoin element's javascript "change" event add the Ajax call to a function in user_ajax.php. Then, in that ajax call "done" function, update your field element with the retrieved value.
 
Last edited:
You can use the same approach as in your other just recently solved thread.

In databasejoin element's javascript "change" event add the Ajax call to a function in user_ajax.php. Then, in that ajax call "done" function, update tour field element with the retrieved value.

Yes, thank you i have never user ajax with fabrik so this will solve so many questions that i have, basicaly Fabrik, joomla and some help what can you do is inlimited!!! thanks again for the answer!
 
Yes, thank you i have never user ajax with fabrik so this will solve so many questions that i have, basicaly Fabrik, joomla and some help what can you do is inlimited!!! thanks again for the answer!

This might be exactly what I'm looking for. Would you be able to tell me exactly what the solution was. I'm not too Javascript savvy.
 
Nevermind! Figured it out. This is great.

For the field element, I used inline JS

Code:
var uid = this.form.formElements.get('afab_bc___member_name').getValue();

jQuery.ajax({
    url: 'https://www.whatever.com/index.php?option=com_fabrik&format=raw&task=plugin.userAjax&method=LegalName&userid='+uid,
    method: 'get',
    context: this
}).done(function (myresult) {
   var UsersLegalName = this.form.formElements.get('afab_bc___legal_name');
   UsersLegalName.update(myresult);
});

Then, you need to go to components/com_fabrik
Locate user_ajax_example.php
Copy user_ajax_example.php and rename it user_ajax.php as a starting point

and for user_ajax.php I added the following terrible function:

Code:
    public function LegalName()
    {

    $app = JFactory::getApplication();
    $input = $app->input;
    $userid = $input->get('userid', '');
  
    $int = (int)$userid;
    $myDb = JFactory::getDbo();
    $myQuery = $myDb->getQuery(true);
    $myQuery->select('first_name')->from('jos_acymailing_subscriber')->where('userid = ' . $int);
    $myDb->setQuery($myQuery);
    $fname = $myDb->loadResult();
    $myQuery = $myDb->getQuery(true);
    $myQuery->select('last_name')->from('jos_acymailing_subscriber')->where('userid = ' . $int);
    $myDb->setQuery($myQuery);
    $lname = $myDb->loadResult();
    echo $fname . ' ' . $lname;
    }

Then after two and a half days of tinkering on and off with this, I smashed my keyboard repeatedly on my forehead screaming "LET'S GOOOOO". Have a great weekend.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top