[{:keys [id Form save-mutation cancel-mutation save-params cancel-params]}]
Render a form in a Semantic UI Modal.
:Form - Required. The form to use for edit/create
:save-mutation - Required. A mutation that will be transacted with the final ident if/when the form is saved.
:cancel-mutation - Required. A mutation that will be transacted if the cancel button is pressed.
:id - Optional. If not supplied will create a new instance. If supplied it will load and edit it.
:save-params - Optional. Extra parameters (beyond the :ident that is auto-included) to pass to the save-mutation:cancel-params - Optional. Parameters to pass to the cancel-mutation
Example usage:
(defmutation saved [{:keys [ident]}]
(action [{:keys [state]}]
(swap! state update-in [:component/id ::Container] assoc
:ui/selected-account ident
:ui/open? false)))
(defmutation cancel [_]
(action [{:keys [state]}]
(swap! state update-in [:component/id ::Container] assoc
:ui/open? false)))
(defsc Container [this {:ui/keys [open? selected-account edit-id] :as props}]
{:query [:ui/open? :ui/selected-account]
:ident (fn [] [:component/id ::Container])
:initial-state {}}
(comp/fragment {}
(when open?
(ui-form-modal {:Form BriefAccountForm
:save-mutation saved
:cancel-mutation cancel}))
(dom/div (str selected-account))
(dom/button {:onClick (fn []
(comp/transact! this [(m/set-props {:ui/open? true})]))} "New")))
```
[{:keys [id Form save-mutation cancel-mutation save-params cancel-params]}]
Render a form in a Semantic UI Modal.
:Form - Required. The form to use for edit/create
:save-mutation - Required. A *mutation* that will be transacted with the final ident if/when the form is saved.
:cancel-mutation - Required. A *mutation* that will be transacted if the cancel button is pressed.
:id - Optional. If not supplied will create a new instance. If supplied it will load and edit it.
:save-params - Optional. Extra parameters (beyond the `:ident` that is auto-included) to pass to the save-mutation`
:cancel-params - Optional. Parameters to pass to the cancel-mutation`
Example usage:
```
(defmutation saved [{:keys [ident]}]
(action [{:keys [state]}]
(swap! state update-in [:component/id ::Container] assoc
:ui/selected-account ident
:ui/open? false)))
(defmutation cancel [_]
(action [{:keys [state]}]
(swap! state update-in [:component/id ::Container] assoc
:ui/open? false)))
(defsc Container [this {:ui/keys [open? selected-account edit-id] :as props}]
{:query [:ui/open? :ui/selected-account]
:ident (fn [] [:component/id ::Container])
:initial-state {}}
(comp/fragment {}
(when open?
(ui-form-modal {:Form BriefAccountForm
:save-mutation saved
:cancel-mutation cancel}))
(dom/div (str selected-account))
(dom/button {:onClick (fn []
(comp/transact! this [(m/set-props {:ui/open? true})]))} "New")))
```
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |