dynamic dropdown

admin_wiky 13 Jan, 2016
Hi Bob, others,

I have a question.
I have CF where I need dynamic dropdown and need to show in text key information from 2 values, which are stored in different tables.
1st table shows all records where 1 column links to 2nd table as unique index.

I did try some options, but I cannot correctly set relation.

could u help me how get 2 values text key in dropdown, which are stored in different tables.
GreyHead 13 Jan, 2016
Hi homeopat,

You could use a DB Read action and set the Relation to the second table - but it's probably simpler to use a Custom Code action to write the MySQL query and get the data that way. You need to add it to the $form->data array as a sub array where each entry has the 'value' and 'text' you need.

admin_wiky 13 Jan, 2016
Hi Bob,
good point😉 second way is faster, I just want to try do in relations.
is it question of select in select and I dont know how set the condition in second table to get name depending on id from first table.
for example: master is list of transactions (where is column id) and second table is list of users.
Can I do virtual columns or overwrite some returning value in DB read action?

GreyHead 14 Jan, 2016
Hi homeopat,

I just use the easy solution. You should be able to use the Relations tab in the DB Read to access the second table using the id to identify the record.

admin_wiky 15 Jan, 2016
Hi Bob,
I understand you, but not sure if is it feasible.
I get 10 records from fisrt table and i need to get names from second table for every record of first table. But dont know how join 2 columns (separate tables) to one column that i send to dynamic dropdown (text key).
I am not sure how get this result (conditions, next modifications in custom code?)

GreyHead 15 Jan, 2016
Hi homeopat,

Have you looked at the Relations tab in the DB Read action?

admin_wiky 18 Jan, 2016
Hi Bob,
Yes, I set relation in DB read, maybe wrong way.
I figure out.

I set the relation type to HasOne a join condition.
Then I put custom code

  $form->data['model_id'][$i]['cislo_model_id']=$form->data[$i]['model_id']['column'].' '.$form->data[$i]['model_id']['column'].' - '.$form->data[$i]['model_id']['column'];
} while (isset($form->data[$i]['model_id']['column']))

and then I get what I wanted to dynamic dropdown
This topic is locked and no more replies can be posted.