This UI component hasn't been finalized yet. The functionality and syntax aren't stable and might be redone in an upcoming release. Only use it at your own risk - breaking changes are likely to occur.
Modal dialogs are used in Kirby's Panel in many places for quick actions like adding new pages, changing titles, etc. that don't necessarily need a full new view. You can create your own modals for your fields and other plugins or reuse our existing modals to invoke typical Panel actions.
The icon type for the submit button
small, medium, large
The modal size can be adjusted with the size prop
The text for the submit button
The theme of the submit button
Dialogs are only openend on demand with the
||Shows the error notification bar in the dialog with the given message|
Opens the dialog and triggers the
||Shows the success notification bar in the dialog with the given message|
This event is triggered whenever the cancel button or
the backdrop is clicked.
This event is triggered when the dialog is being closed.
This happens independently from the cancel event.
This event is triggered as soon as the dialog opens.
This event is triggered when the submit button is clicked.
By default, the dialog component is coming with cancel and submit buttons in the footer. You can control those with the dialog props.
If you need more control over the available buttons in the footer, or you want to create a dialog without buttons, you can overwrite the footer slot.
A dialog can easily be combined with a form by using the
k-form component. It's important though to setup the submit events correctly.
As you can see in the example, the
@submit event of the dialog is used to trigger the
submit() method of the form. The
@submit event of the form is then used to actually trigger the defined submit method.
In the submit method the API call is done. On success, the dialog will be closed, while
catch() will take care of showing the error notification bar in the dialog and keep it open.
By setting up the dialog and form like this, you can make sure that the ok button and any submit events within the form (i.e. enter key) are doing the same.