RSjoomla! - Quality Joomla! Components

My Account






Lost Password?
No account yet? Register

Newsletter Subscribe

If you would like to be one of the first people to hear about the release of our new components then make sure you have subscribed to our announcements list! We won't bug you with unnecessary stuff.




RSform! Logo User Guide

Populate Select List from external tables 

In order to populate a selectbox field with values taken from an external table, you'll have to paste this script in the Scripts called on form Display, and change col1, col2 and my_external_table to match your needs.

 

foreach($fields as $i=>$field){
    if($field->name=='select1'){
        $database->setQuery("SELECT col1 as val, col 2 as txt FROM my_external_table");
        $values = $database->loadObjectList();
        $default_value = array();
        foreach($values as $row){
            $default_value[]= $row->val.'|'.$row->txt;
        }
        $default_value = implode(',',$default_value);
        $fields[$i]->default_value = $default_value;
    }
}