# Adding a combo box to the modules settings config panel, which is bound to string field in settings record

**URL:** <https://forum.inductiveautomation.com/t/adding-a-combo-box-to-the-modules-settings-config-panel-which-is-bound-to-string-field-in-settings-record/71781>\
**Category:** Module Development\
**Created:** [March 29, 2023, 3:56pm UTC](https://forum.inductiveautomation.com/t/adding-a-combo-box-to-the-modules-settings-config-panel-which-is-bound-to-string-field-in-settings-record/71781 "2023-03-29T15:56:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denis\_Cote](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@Denis\_Cote](https://forum.inductiveautomation.com/u/Denis_Cote)\
**Post date:** [March 29, 2023, 3:56pm UTC](https://forum.inductiveautomation.com/t/adding-a-combo-box-to-the-modules-settings-config-panel-which-is-bound-to-string-field-in-settings-record/71781/1 "2023-03-29T15:56:19Z")

</div>

Does anyone have an example of how to do this.

Thanks!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 29, 2023, 4:22pm UTC](https://forum.inductiveautomation.com/t/adding-a-combo-box-to-the-modules-settings-config-panel-which-is-bound-to-string-field-in-settings-record/71781/2 "2023-03-29T16:22:44Z")

</div>

A combobox with a fixed list of options, or does it need to be a dynamic list from somewhere?

Either way - the gist is you need to set the editor source for your StringField. In a static block in your PersistentRecord implementation, do something like:

```java
MyField.getFormMeta().setEditorSource(yourEditorSource)

```

Where yourEditorSource needs to implement [`IEditorSource`](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.26/com/inductiveautomation/ignition/gateway/web/components/editors/IEditorSource.html).  
The newEditorComponent returned should probably extend AbstractEditor. Something like this:

```java
public class LanguageEditor extends AbstractEditor {

    public static final Comparator<Locale> LOCALE_COMPARATOR = 
        Comparator.<Locale, String>comparing(Locale::getDisplayLanguage, String.CASE_INSENSITIVE_ORDER)
            .thenComparing(Locale::getDisplayCountry, String.CASE_INSENSITIVE_ORDER);

    public LanguageEditor(String id, FormMeta formMeta, RecordEditMode editMode, SRecordInstance record) {
        super(id, formMeta, editMode, record);

        LanguageDropdownChoice dropdown = new LanguageDropdownChoice("editor");

        formMeta.installValidators(dropdown);

        dropdown.setLabel(new LenientResourceModel(formMeta.getFieldNameKey()));

        add(dropdown);
    }

    private class LanguageDropdownChoice extends DropDownChoice<Locale> implements IRecordFieldComponent {

        public LanguageDropdownChoice(String id) {
            super(id);

            List<Locale> choices = new ArrayList<>();
            Collections.addAll(choices, Locale.getAvailableLocales());
            choices.sort(LOCALE_COMPARATOR);

            setChoices(choices);
            setChoiceRenderer(new ChoiceRenderer<>() {
                @Override
                public Object getDisplayValue(Locale value) {
                    if (value == null) {
                        return null;
                    }
                    return String.format("%s (%s)", value.getDisplayLanguage(),
                        StringUtils.isBlank(value.getDisplayCountry()) ? "General" : value.getDisplayCountry()
                    );
                }
            });
        }

        @Override
        public SFieldMeta getFieldMeta() {
            return getFormMeta().getField();
        }

    }

    public static class LanguageEditorSource implements IEditorSource {
        public static final LanguageEditorSource INSTANCE = new LanguageEditorSource();

        @Override
        public Component newEditorComponent(String id, RecordEditMode editMode, SRecordInstance record,
                                            FormMeta formMeta) {
            return new LanguageEditor(id, formMeta, editMode, record);
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 29, 2023, 4:23pm UTC](https://forum.inductiveautomation.com/t/adding-a-combo-box-to-the-modules-settings-config-panel-which-is-bound-to-string-field-in-settings-record/71781/3 "2023-03-29T16:23:32Z")

</div>

The easiest way to get Comboboxes in Ignition's Wicket infrastructure is to use the EnumField, not strings.

---

<div class="post-metadata">

**Author:** ![Denis\_Cote](https://avatars.discourse-cdn.com/v4/letter/d/ecb155/32.png) [@Denis\_Cote](https://forum.inductiveautomation.com/u/Denis_Cote)\
**Post date:** [March 29, 2023, 4:30pm UTC](https://forum.inductiveautomation.com/t/adding-a-combo-box-to-the-modules-settings-config-panel-which-is-bound-to-string-field-in-settings-record/71781/4 "2023-03-29T16:30:18Z")

</div>

Yes , thanks all. I would prefer enum and found this in the API for field types. Thanks!
