How to use calc element to find value from another table element?

Status
Not open for further replies.

jmdc

Member
Hello,

I am trying to have the same value in elementnameA, like {listA___elementnameA} = {listB___elementnameB} knowing that elementnameB is a dropdown element with these values:
1 - Yes
2 - No
3 - Maybe

I am only able to have the same values, but i am not able to find out how i can have the labels.

In my code, i have in {listA___elementnameA} which is a calc element:

$db = JFactory::getDbo();
$myQuery = 'SELECT elementnameB FROM listB WHERE xxx...;
$db->setQuery($myQuery);
$name = $db->loadResult();
return $name;

And it gives me the {1, 2 or 3 }, but i would like to have labels {Yes, No or Maybe} instead of values.

Could you help me, please?

Thank you.
 
I think you can try to use or an autofill form plugin or a cascading dropdown looking at list B based on list A value
 
Thank you, but the autofill form plugin is not dynamic. Do you think i have to use list joins??
 
Could you explain better the context of what you are trying to achieve maybe giving a clear sample ?

Do you have to update list A with B value when a form is submitted or do you have to update an element on the form according to changes of another element ?

I think that fabrik offers several way to achieve a goal .... chosing the best depend on context.

If I didn't misunderstand what you are trying to do If you hardcoded dropdown B value on element settings I could suggest to create a table\list with the dropdown value and then use on list A a dbjoin element that point to B table. In that way should be easier retrieve a label according to raw value as If i'm not wrong cdd ad dbjoin provide a kind of auto bridge between raw_values and labels


I'm still a fabrik beginner and I'll be glad to give you some hints according to my knowledges but surely someone more used to fabrik can give you a better or smarter help
 
Why do you use {1, 2 or 3} as values? Would it be an option to set as:
Value - Label
Yes - Yes
No - No
Maybe - Maybe

There is probably several ways. I would use javascript to do a change or click event on elementnameB and update elementnameA on click or change. elementnameA would than be a regular field.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top