There are few utility functions like fieldsToTable that contsruct a form in particular layout (one column table, divs etc.) But often we need to construct a form with custom layout. How do i get individual rendered form fields (in a list or map) to splice them into my template the way i see fit ? Regards, Vagif Verdi
On Sun, Mar 20, 2011 at 6:27 PM, <vagif.verdi@gmail.com> wrote:
There are few utility functions like fieldsToTable that contsruct a form in particular layout (one column table, divs etc.) But often we need to construct a form with custom layout. How do i get individual rendered form fields (in a list or map) to splice them into my template the way i see fit ?
I apologize in advance for the vagueness of this email, I don't have time to give it a proper answer currently. Hopefully others can help flesh out the details until I have a bit more time to explain properly. The datatypes from yesod-form provide both an Applicative and a Monad interface. The Applicative interface gives you very terse code at the cost of constraining your output. Monad will require a bit more typing but gives you complete freedom of display. Michael
I have a single field form that uses the following code, hopefully it gives you a good idea: mkPersist [persist| Query term String |] runSearchForm = do ((res, form), _) <- runFormMonadGet queryForm return (res, form) where queryForm = do (term, queryField) <- searchField True "Search" Nothing return (Query <$> term, [hamlet| ^{fiInput queryField} |]) On Sun, Mar 20, 2011 at 10:52 AM, Michael Snoyman <michael@snoyman.com>wrote:
On Sun, Mar 20, 2011 at 6:27 PM, <vagif.verdi@gmail.com> wrote:
There are few utility functions like fieldsToTable that contsruct a form in particular layout (one column table, divs etc.) But often we need to construct a form with custom layout. How do i get individual rendered form fields (in a list or map) to splice them into my template the way i see fit ?
I apologize in advance for the vagueness of this email, I don't have time to give it a proper answer currently. Hopefully others can help flesh out the details until I have a bit more time to explain properly.
The datatypes from yesod-form provide both an Applicative and a Monad interface. The Applicative interface gives you very terse code at the cost of constraining your output. Monad will require a bit more typing but gives you complete freedom of display.
Michael
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
participants (3)
-
Greg Weber -
Michael Snoyman -
vagif.verdi@gmail.com