I have two related tables. I want to add a dropdownlist to the CGridView such that it populates only those values that match the id(FKey) of the another table. I went through many related post but found no solution. Could anyone help me or guide me?
Perhaps no one has replied because your question is a bit unclear.
Questions:
Are you trying to browse the Parameters, or ConditionParameters?
My guess is: you’re trying to browse Parameters, one Parameter per line. Is that true?
In the view, next to each Parameter name, you want a dropdown
showing all Conditions matching parameter_id, right?
In the view, what is the purpose of showing the Conditions in a dropdown?
CGridView is meant for viewing, not for updating, so I don’t see why it’s
useful to display the set of Conditions as a dropdown. Why not just
display each condition, separated by newlines?
Your schema. Your database table and column names seem strange to me. E.g.,
a. Why is Parameters plural, but ConditionParameter is singular?
b. In your parameters table, your column names repeat the table name.
You have parameters.parameter_id and parameters.parameter_name
Why not the simpler, and more standard names, like below:
parameters.id, parameters.name
I’ll check on this in the a.m. if no one else has replied.
In the view, what is the purpose of showing the Conditions in a dropdown?
CGridView is meant for viewing, not for updating, so I don’t see why it’s
useful to display the set of Conditions as a dropdown. Why not just
display each condition, separated by newlines?
Stated another way, a dropdown is intended to allow the to select one value from a set of many. But your parameters table has a one-to-many relationship with your parameter_conditions table, so it makes no sense (to me) to just choose one.
here para is the relation name, but not working as expected. May be since para.cond_parameter is an array of value. Dont know how to sort out this problem.
According to my understanding of your schema, the foreign relation is in the ConditionParameter table, not in the Parameters table. So, when browsing the Parameters table, you cannot refer to ‘para.cond_parameter’, because it does not exist; i.e., it does not get returned by the relations() function of the Parameters A/R class.
I’m going to sign off of this thread because I’ve run out of time. Best of luck!