lcharette / UF_FormGenerator

Form Generator sprinkle for Userfrosting 5
MIT License
17 stars 4 forks source link

Seeking programmatic launch of Modal Form (no button, no anchor click) #11

Open frankfont opened 5 years ago

frankfont commented 5 years ago

From conversation on 2/24/2019 confirmed there is no API at this time for programmatic launch of a modal form in UF_FormGenerator. The methods that do it are private behind the existing API.

In my case, I don't have a button and don't have an anchor tag in the UI that a click event can be bound to in the normal way. Instead, I need to launch the modal form from javascript in a custom event handler function provided by a context menu framework I'm using.

Enhancement request: Provide a public method that displays the modal form so that click event element binding is not required. For example ...

formGenerator.displayForm(options) { ... }
lcharette commented 5 years ago

Agreed. The only way to create a modal right now is through an onClick event bind to an HTML element : https://github.com/lcharette/UF_FormGenerator/blob/54142114c2180ab3e57c539ab881021915a48831/assets/js/widget-formGenerator.js#L47-L53

The _fetchForm private method (private, so can't be called manually) should be refactored, mostly to remove the event argument and provide normal options instead. The display method should be refactored and define the click event as an option. It could also be renamed to something clearer (with keywords like attach or bind) to make it clearer it purpose is to bind something to the element it's applied on.

Same goes for the confirmation modal.