Hi All,
I have three dropdown lists in an view having a jModelAdmin as the model. These dropdown lists all extends jFormFieldList.
The second list is dependent of the first list selected value and the last list is dependent of the second list's selected value. A drilldown kind of approach.
This is easy to do with javascript loading list options with ajax - javascript is the best way of going when creating a new record (id=0)
But when you are in edit state the javascript approach is not that elegant. For that reason i am using php populate options and uses some where clauses to filter the dropdown lists but when the application is loaded the first time the list are not changeable.
I like the dropdown lists to change there lists dynamically any ideas of how I can accomplish this? Here is a sample of second dropdown of how i populate the dropdown:
private function fetchList($table = '#__area', $field = null, $selectedCountry){
// Create a new query object
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Select some fields
$query->select("ID as value, {$field} as text
FROM
{$table}");
if(isset($selectedCountry)){
$query->where("(id_country = {$selectedCountry})");
}
$db->setQuery($query);
$areas = $db->loadAssocList();
return $areas;
}
method above is used by getOptions() to get $selectedCountry I use: $selectedCountry = $this->form->getValue('id_country');