dynamic lookup list for single select field

Herman Hebbink

New member
I have a single select field on a form and the list of choices is dependend on the value of another field on that same form. I see there is an option to add a where clause to the selection of the list, but is it possible to use the value of another field in that where clause ?

My situation is that I have a form that represents a sports game. The game is related to a league and the selection of the competing teams is limited to those teams that play in that league.
 

eugenio

Administrator
Staff member
Hi,
what you probably want is a cascading listbox, i.e. a listbox with choices that change based on the value a user selected in another listbox. This feature is currently not available in DaDaBIK.
 

Herman Hebbink

New member
Hello Eugeno,

Thanks for your answer. For now, I used a quick and dirty work around which allows me to use %columname% constructions in the where clause of a single_select. To make this work I made the following modification in your "business_logic.php" :


...
if ($where_clause_field != ''){

// HHE - give it a try
foreach( $details_row as $key => $value ) {
$from[] = "%$key%" ;
$to[] = $value ;
}
$sql .= " WHERE ".str_replace( $from, $to, $where_clause_field ) ;
}
...

With this I can use the values of the current record in the where clause of the single select field like:

parent = '%id%'

maybe an idea for a next version ?
 
Top