mcintyre321 / FormFactory

MVC5, Core or standalone - Generate rich HTML5 forms from your ViewModels, or build them programatically
http://formfactoryaspmvc.azurewebsites.net/
MIT License
304 stars 102 forks source link

How to handle form submit + put values into a view model #45

Closed juanonsoftware closed 7 years ago

juanonsoftware commented 7 years ago

Hello, FF works great when creating a form programatically (fields are displaying well). But when I submit the form, I'd like to find a efficient way to bind to the model. Do you have an example about this? Or any suggestion? Thanks

mcintyre321 commented 7 years ago

What Type is the model? Do you have examples of the data?

If it's not a Type (e.g. it's data driven), you can use a ModelBinder that binds to JObject* then use code to take values from the JObject.

If you get stuck (or even if you get it working!) you could add an example to the Example app and i can take a look

On 30 Mar 2017 05:53, "Juan on Software" notifications@github.com wrote:

Hello, FF works great when creating a form programatically (fields are displaying well). But when I submit the form, I'd like to find a efficient way to bind to the model. Do you have an example about this? Or any suggestion? Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mcintyre321/FormFactory/issues/45, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ0-jjhAbo0t983EM0wreQiYU7Dcl7cks5rqzVTgaJpZM4Mt3Pv .

juanonsoftware commented 7 years ago

In fact I try your example on "Programatically created form". So the model is dynamic, it will have field define dynamically. I have created a custom ModelBinder and it works on basic types (manually convert from string to the type I want and put values into a Dictionary).

mcintyre321 commented 7 years ago

Nice, that's a good solution.