agocorona / MFlow

(Haskell) Web application server with stateful, type safe user interactions and widget combinators
http://mflowdemo.herokuapp.com
Other
100 stars 12 forks source link

Case for handling implicit/explicit forms with <|> #52

Closed BartAdv closed 10 years ago

BartAdv commented 10 years ago
test = step $ do
  i <- page $
         (wform $ getInt (Just 1)) <! [("class", "foo")]
       <|> do
             submitButton "ok"
             --noWidget -- works if there is widget that does not produce HasElems
             return 0

  page $ p "hola" ++> noWidget

In above case, my explicit form laters gets removed and replaced by implicit one (it manifests with removal of class main-form). I've tracked this to the controlForms function, and noticed some commented out code - why was that, and is this pull request correct then? (In my case it is).

agocorona commented 10 years ago

I did not find a way to handle all the cases, and sometimes the commented code produced undesired results. But I don´t know now how to reproduce the problem. It should be a matter of uncommenting it and running some form examples in demos-blaze, specially the latter ones. But I can not do it now. Currently controlForms only handles the opposite case: when the first form is implicit and the second explicit.

You can make it work if you make explicit the second form with wform $ submitButton "ok"

BartAdv commented 10 years ago

I might check some - but I did not simply uncommented the code, I just replaced it with analogue code to the one that was there (the commented out used ++, no idea why)

agocorona commented 10 years ago

Thanks. The ++ is because it is old code, when the rendering of the widget was defined as a list of renderings.

BartAdv commented 10 years ago

GenerateForm (only versions without autoRefresh) - cannot prepare group for checkboxes/options, but it doesn't seem to be caused by that change.

agocorona commented 10 years ago

The error is reproducibe in mflowdemo.herokuapp.com?

2014-08-05 12:32 GMT+02:00 Bartosz notifications@github.com:

GenerateForm - cannot prepare group for checkboxes/options, but it doesn't seem to be caused by that change.

— Reply to this email directly or view it on GitHub https://github.com/agocorona/MFlow/pull/52#issuecomment-51179954.

Alberto.

BartAdv commented 10 years ago

Nope

BartAdv commented 10 years ago

Aha, I know what it breaks - dynamic widgets end up having 'send' button in different form than the rest of the widget

agocorona commented 10 years ago

I found no way to handle all the cases automatically.

2014-08-07 10:23 GMT+02:00 Bartosz notifications@github.com:

Aha, I know what it breaks - dynamic widgets end up having 'send' button in different form than the rest of the widget

— Reply to this email directly or view it on GitHub https://github.com/agocorona/MFlow/pull/52#issuecomment-51443989.

Alberto.

BartAdv commented 10 years ago

Yeah, maybe there is no point trying to.