AnsweredAssumed Answered

How can I popupate a dropdown list from a table.

Question asked by delsugar on Mar 11, 2016
Latest reply on Oct 11, 2018 by Angel Martinez





Can someone provide an example as to how to populate a dropdown list from a table. The example from sugar does not appear to work for me.


Ideally I would like to populate a dropdown from a table but I am trying to just implement the following sample code from sugar at exactly as is and it does not work.
I see my code loop though in sugarlog but nothing gets update.




private function syncDropdown($dropdown)


        $parameters = array();

        $parameters['dropdown_name'] = 'my_list';

        $listValues = array(

        'Key_Value_1' => 'Display Value 1',

        'Key_Value_2' => 'Display Value 2',

        'Key_Value_3' => 'Display Value 3'


        $count = 0;

        foreach ($listValues as $key=>$value)


            $parameters['slot_'. $count] = $count;

            $parameters['key_'. $count] = $key;

            $parameters['value_'. $count] = $value;

            //set 'use_push' to true to update/add values while keeping old values

            $parameters['use_push'] = true;


            $GLOBALS['log']->security('dropdown='.$dropdown['name'].' value='.$value);