Get a value from a databasejoin element (other list)

juandress

New Member
Hi , I need to get a value from a previously selected databasejoin element.

I think about using a calc element to get the value of the other table, but I've looked for a simple way to solve it and it has not worked.

example
In form.
Select Agency (databasejoin element) (list with code agency, name, boss, idboss)

Calc Element, use php as return {other list} .idboss;

then, I can use the calc element for pre filter.

Please , help me
Thank you in advance.

Juan
 
Not sure what you mean.
In a database join element you can select the "Value" (is stored in the database and should be the primary key of your lookup-table, usually id[recommended]) and you can select the "Label" (shown to the user, which can be any column of your lookup-table or a concatenation defined in "or Concat label")
 
You are right, I knew it was like that but at the beginning I did not show it well. I tried it and it's fine for what I need.

Thank you so much
 
Hi troester , It may be that when I use a calc element to use a select it does not give me the result because it takes the value of the label and not the field.

How can I read the field value in the select
field databasejoin plugin
{tareas___usuario_asignado} setup
label = table.agencia, ' | ' , table.name
value= id


Ex. calc field
$id = {tareas___usuario_asignado}; (take the label instead of the value) table.agencia, ' | ' , table.name) resul = Null ----- if I put a constant value 855 the resul is email@email.com
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('email');
$query->from($db->quoteName('AGENCIASUSUARIOS'));
$query->where($db->quoteName('id').' = '.$db->quote($id));

$db->setQuery($query);
$email = $db->loadResult();

return $email;

How can you read the value of the combobox directly
When I record the usuario_asignado field it puts the value correctly

Please , Thank you for your answer

Juan
 
Also, always quote placeholders in your PHP code, like ...

Code:
$id = '{tareas___usuario_asignado_raw}';

If you don't do that, and the element is empty, you'll get a fatal syntaxt error.

Also, if you are expecting an integer to use as an FK in a query, you can cast it to an int ...

Code:
$id =(int) '{tareas___usuario_asignado_raw}';
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top