danielo515 / obsidian-modal-form

Define forms for filling data that you will be able to open from anywhere you can run JS
https://danielorodriguez.com/obsidian-modal-form/
MIT License
187 stars 14 forks source link

[Bug] select doesn't get prepopulated with initialValue #233

Closed hammonia-io closed 2 months ago

hammonia-io commented 5 months ago

Is your feature request related to a problem? Please describe. I'm using obsidian-modal-form to edit existing data. For some of the data i use fixed selects. While most field types that i tried can be prepopulated with initial data of an existing object, for select fields this doesn't work.

I'm using the plugin like this, the initialData is in the object itemValues:

        const modalForm = app.plugins.plugins.modalforms.api;
        ...
        const result = await modalForm.openForm({
            title: "Edit item",
            fields: formFields
        },{
            values: itemValues
        });

Describe the solution you'd like I think the relevant code is found here, https://github.com/danielo515/obsidian-modal-form/blob/master/src/FormModal.ts Line 211ff

Fatebreak commented 5 months ago

Another is with the Dataview field! I would love to be able to prepopulate the field by passing in a value, but if I decide to change it in the form to have the Dataview functionality

danielo515 commented 2 months ago

I think this has been fixed already