Populate a dbjoin element based on another element

madpato

Member
Hello

I have the following situation: I have a dbjoin element that when selected shows certain information on another calc element (based on the selection of the dbjoin element). So far no problems there, but what if i need to modify the information of that calc element only in that record? (which exists in another table and is where the calc element gets the information, i would be need to with a dropdown select another option).
I was thinking on using another dbjoin element to do the calculation that my calc element does but its not working i have enabled eval and set the same code on the default field of the dbjoin:

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);

$myQuery
    ->select('vehiculo_conductor')
    ->from('mant_trabajadores')
    ->where('nombre_trabajador =' . $myDb->quote('{ots___conductor_ot}'));

$myDb->setQuery($myQuery);
$patente = $myDb->loadResult();
return $patente;

But its not working, any help is appreciated. Regards
 
... what if i need to modify the information of that calc element only in that record?
From what I understand, if you want to have the calc element storing different information for e.g. only one record, you certainly know which record this is. For example, you know its ID, or you base it on other element values in its list.
So, then you wrap your calc element code into an "if ... else", like so:
Code:
if ('{table___element}' == 123) {
    // return your exceptional, different value
} else {
    // do and return your usual stuff
}
Also, in your DB query code:
• Since loadResult() returns only a single value, are you sure that the "where" condition finds only one and not multiple?
• What element type is {ots___conductor_ot}? Could it be that you'll need to append _raw?
 
Hello thank you for your reply. Let me explain a bit more because i dont need a calc element (is what i am using but found that is not viable for what i need to achieve).
When i am entering a new entry on my form, on my dbjoin element (which is a dropdown) I select a person and that person is associated with a specific value from another table (lets call it table A), BUT sometimes we need to change that value from a list that is located in another table (table B). But only for this entry on this form.

If i use a calc element i dont have access to the list of table B thats why i think i need to use another dbjoin element. I have attached a small image maybe that makes things more clear on what i need. Thanks a lot.
 

Attachments

  • Captura.JPG
    Captura.JPG
    42 KB · Views: 51
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top