MangelMaxime / Fable.Form

Home Page:https://mangelmaxime.github.io/Fable.Form/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add "onCancel" functionality

zelenij opened this issue · comments

commented

At the moment there is no way to explicitly abandon the form - i.e. I can't see how a "Cancel" button can be added. This is a standard usability feature. At the moment I'm stuck on the form page, and either have to put a button somewhere before/after it, or navigate away by the means of "back" navigation or using navbar, if there is one.

I'm sure I can add the necessary code myself - would you accept the PR if it's working?

Hello @zelenij,

Right now, the only way to add the cancel button inside the form would be to write your own form logic.

But it does make sense to have a cancel button natively included in the default library.

I'm sure I can add the necessary code myself - would you accept the PR if it's working?

Yes :)

commented

I created a PR. It compiles, but I'm not sure how to run the example project from the code base...

Hello,

you can find in the README instruction about the main script used in this repository:

https://github.com/MangelMaxime/Fable.Form#development

To run the examples, you can use npm run watch-examples

commented

OK, will take a look, thanks

commented

Interesting, Fable seems to be generating an unconditional throw for my code, any idea why?

This

                                match cancelPolicy with
                                    | CancelPolicy.DoNothing -> Html.none
                                    | CancelPolicy.Action action ->
                                        Bulma.button.button [
                                            color.isLight
                                            prop.text "Cancel"
                                            prop.onClick (
                                                fun _ -> 
                                                    JS.consoole.log("Triggering cancel")
                                                    action()
                                            )
                                        ]                                

gets converted into this:

image

You wrote consoole instead of console

A new version has been released, and this version allows you to control the area section of the form.

I find it a better solution, because you can add any number of controls in it and you can also control the visual display of the area for example, if you prefer to have the buttons center etc.

Example is available here:

https://mangelmaxime.github.io/Fable.Form/examples/index.html#custom-actions

commented

Thanks! Yes, there is an extra o there :) I wonder why the compiler didn't catch it...