this will tell the fieldset it's a select, and what the default value on an emtpy form is.
To load the data, there are multiple options, depending on what it is. If it's (virtually) static data, like available languages in this example, I load it in the models _init() method, using
public static function _init() { // load the available languages for this app from the settings table static::$_properties['language']['form']['options'] = \Settings\Load::settings('LANGUAGE', null); }
(note: settings is a package we use in our apps, it returns a key-value array, 'EN' => 'English')
If it is dynamic data, you would want to load it before generating the form. In that case you do it in set_form_fields() method:
public static function set_form_fields($form, $instance = null) { // add the csrf token field to the form $form->form()->add_csrf();
// create the base fieldset parent::set_form_fields($form, $instance);
// add the meta data correspondence fields foreach (array('mailcalled', 'mailresults', 'mailcerts', 'mailinvoice') as $field) { $form->field($field)->set_options(\Settings\Load::settings('MAILTO', null)); } }
(again, this is a specific example from one of our apps)