• 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.

$opt->value: explode using separator in a dbjoin element

mirceat

Member
Hello

can i explode $opt->value using a delimiter and populate a dbjoin element with the array values? I'm using a dbjoin because the values are dinamically retrieved from database.

Let's say the $opt->value looks like (string) "value1|value2|value3". I tried to convert this string to array using explode and populate the dbjoin options, but all i can get is value = "value3", label = "value3"

Code:
$tests = explode("|",$opt->value);
foreach ($tests as $test) {
$opt->value = $test;
$opt->text = $test;
}

How can i populate the dbjoin element like:

<select name"..">
<option value="value1">value1</option>
<option value="value2">value2</option>
<option value="value3">value3</option>
</select>

Thank you
 
Can i retrieve dynamic values in a dropdown? If yes, how?
The dbjoin element is using a where condition like "where {thistable}.id = '{table___elementname}'", i tried with a query in dropdown but it's not working, the placeholder value is not retrieved..
 
We should be doing a placeholder replacement on your code, but you may be better off finding it yourself, with something like ...

Code:
$formModel = $this->getFormModel();
// form data should be in $formModel->data, you can test by dumping it out here ...
var_dump($formModel->data); exit;

-- hugh
 
I'm still confused: how can i retrieve the data dinamically from another element using dropdown and php code as troester says above?

I tried with placeholder (the value is not retrieved dinamically as oposite to dbjoin element where an ajax call is triggered) and also using formModel (didn't know that i can use it in elements, not only for php form plugin), i can't make it work..

Let's say i have the following php code in the Advanced tab for a dropdown:

Code:
$formModel = $this->getFormModel();
$user_id = $formModel->data['test___user_raw'][0]; //test___user is an "user" element
$db = JFactory::getDbo();
$db->setQuery('SELECT id, name as text FROM #__users where id = '.$user_id.'');
$rows = $db->loadObjectList();
foreach ($rows as $row) {
    $options[] = JHTML::_('select.option', $row->id, $row->text);
}
return $options;

When i load the form, I'm already selected in dropdown. So far so good, the value is retrieved from the test___user element.

But soon as i choosed another User from test___user, the dropdown option is not dinamically updated. That's why i choosed dbjoin element and asked how to split the $opt->value..

Thank you
 
You should set up your dbjoin list as a "clean" lookup table, already with splitted values/text.
 
The dbjoin values will be added by specific users (Product Manager) in an existing form. Basically, the PM will add a simple value that will be autofilled in a field element displayed for agents or will add a "collection" of values that will be displayed in a dbjoin element for agents. It's like a form created by Super User that will be visible only for PM and all the values filled by PM will be displayed in another form for agents.

In the end i will activate the Frontend option for dbjoin and ask PM to add the values here and fill a db table..never used this option before, let's hope it will solve my request.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top