I built a WebSharper formlet using the combinators, but my goal is to embed it in a jQueryUI pop-up. As a consequence I need to be able to close the dialog when the user clicks no, the following doesn't work:
let confirmationForm order =
let title = DialogConfiguration(Title = "Are you sure you want to place the order?")
let form = Formlet.Return ()
|> Enhance.WithCustomSubmitAndResetButtons
{ Enhance.FormButtonConfiguration.Default with Label = Some "Yes" }
{ Enhance.FormButtonConfiguration.Default with Label = Some "No" }
|> Enhance.WithFormContainer
let rec dialog = Dialog.New(Div [ result ], title)
and result =
Formlet.Do {
let! _ = form |> Enhance.WithResetAction (fun _ -> dialog.Close(); true)
dialog.Close()
return Server.SubmitOrder order
} |> Enhance.WithFormContainer
(dialog :> IPagelet).Render()
Formlet.Do {
let! order = orderForm
return confirmationForm order
}
|> Enhance.WithFormContainer
The dialog closes fine on clicking yes. Also I don't understand the signature requiring me to provide a function that returns true, that is kind of confusing as I do not need to supply any other callback.
Also, note that I am positively surprised that it supports mutually recursive function to allow to provide the workflow to the Dialog's Div. I'm assuming there would be a better way to do this though?
Thanks!