Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i change a value in a view? #121

Open
DanielCollins opened this issue Jul 27, 2015 · 4 comments
Open

how can i change a value in a view? #121

DanielCollins opened this issue Jul 27, 2015 · 4 comments

Comments

@DanielCollins
Copy link

after using postForm, if there are form errors, i get a view value. I cannot work out how to reset some of the form values held in the view before re-displaying the form. Specifically, my captcha should be regenerated with each request so as to prevent unlimited captcha attempts.

@winterland1989
Copy link

I came across the exactly problem as yours, here 's my solution:

import           Text.Digestive.Types
import           Text.Digestive.View
...
lform <- getForm "profile" (profileForm u')
let lform' = lform {viewInput = [
    (toPath "email", TextInput $ sUserEmail user)
    ,   (toPath "desc", TextInput $ sUserDesc user)
    ]}
...

Not nice but do solve the problem, we should providing a helper to do this kind of things, for example, set some pre-defined values in views.

@DanielCollins
Copy link
Author

thanks @winterland1989 this is workable

@winterland1989
Copy link

@jaspervdj Do you think we should add some APIs to poke around view?

@jaspervdj
Copy link
Owner

Yes, I wouldn't mind having an API which allows you to set these values in a more convenient way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants