Include WHERE with get_dropdown_values

QuestionsInclude WHERE with get_dropdown_values
dai asked 11 months ago

For get_dropdown_values, Is it possible to grab a value from the current row but a different column and implement WHERE to filter the possible values?
TABLE #1: task
Column:  name, project_id, milestone_id
Data: my task, 3, 7
Table #2: milestone
Column: id, name, project_id
Data: 7, planning, 3
Data: 8, maintain, 4
Data: 9, evaluate, 3
When editing the row from Task, have a drop down for the milestone column to use the value “3” from the column “project_id”.

$str = $g->get_dropdown_values("select distinct id as k, name as v from milestone WHERE {project_id} ");

Which would execute: select distinct id as k, name as v from milestone WHERE project_id=3
And pull down to generate the value “planning” and “evaluate”

1 Answers
Abu Ghufran Staff answered 11 months ago

With that dropdown, you need to have following code:
$str = $g->get_dropdown_values("select distinct id as k, name as v from milestone");
$col[“editoptions”] = array(“value”=>$str);
$col[“editoptions”][“onload”][“sql”] = “select distinct id as k, name as v from milestone WHERE project_id = {project_id}“;
Removed where condition from get_dropdown() and added “onload-sql” option.

Abu Ghufran - Dev Team
PHP Grid Framework
Your Answer

7 + 0 =

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!