[web-devel] Multi-selects for yesod-form in, let's keep rolling
Michael Snoyman
michael at snoyman.com
Fri Jun 24 11:24:20 CEST 2011
Hi all,
David McBride has implemented multi-selects in yesod-form (way to
go!). This involves a breaking change to the API. So while we're
already breaking things, I wanted to get some discuss
dynamically-increasing forms in a more concrete way.
I've been playing around with a possible API, and came up with
something usable. You can see the result in Github:
https://github.com/snoyberg/yesod-form/blob/master/Yesod/Form/MassInput.hs
. You can also see a usage example in the getMassR handler in the
hello-forms demo:
https://github.com/snoyberg/yesod-form/blob/master/hello-forms.hs
For now, the basic idea is that you'll provide inputList with a label
for this set of fields, some way to convert the list of FieldViews
generated by the individual values into a widget, and a widget for a
single view. inputList will then create a single field in the larger
form, the will contain within it multiple subforms. Each subform will
have an option to delete it in addition to its normal contents. At the
end of the list of subforms, there is a checkbox to add an extra row.
My first use case for this is for creating pages in the Yesod wiki,
and I *think* it will work well for that case (though I haven't tried
it out yet to be sure). I wanted to get input from others about this,
since this is a complicated feature that could go in many different
directions. One thing to point out is that this API only addresses
applicative forms, not monadic forms.
Michael
More information about the web-devel
mailing list