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

Database Generated Nested Forms #81

Closed acesaver closed 5 years ago

acesaver commented 5 years ago

I am trying to create the form driven from a database. The database contains a bunch of options and I use those options to create an array of the PropertyVM objects (like on the sample site). However, i am trying to re-create the nested sample. Would it be possible for you to send me an example of the "Nested Forms" in the format of an array of PropertyVM objects? I have looked at the other potentially related issues but nothing i am doing seems to work.

Here is the error message i am getting: https://pastebin.com/j14NeNMH

I guess it boils down to not understanding how the "nested forms" example translates into the flat PropertyVM array. Any help you could provide would be extremely useful.

Thanks

Regards,

mcintyre321 commented 5 years ago

Hi Martin,

You're on the right track I think, but Im on holiday and don't have access to a computer at the moment. it might be worth you debugging the example project, and looking at the nested forms example model, or .Dump ing it in LinqPad so you can get a handle on what object you need to create

On Fri, 26 Apr 2019, 00:25 Martin Fowler, notifications@github.com wrote:

I am trying to create the form driven from a database. The database contains a bunch of options and I use those options to create an array of the PropertyVM objects (like on the sample site). However, i am trying to re-create the nested sample. Would it be possible for you to send me an example of the "Nested Forms" in the format of an array of PropertyVM objects? I have looked at the other potentially related issues but nothing i am doing seems to work.

Here is the error message i am getting: https://pastebin.com/j14NeNMH

I guess it boils down to not understanding how the "nested forms" example translates into the flat PropertyVM array. Any help you could provide would be extremely useful.

Thanks

Regards,

— 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/81, or mute the thread https://github.com/notifications/unsubscribe-auth/AACDJ6X55ZZZ3LDAGMUNBP3PSIOU5ANCNFSM4HIQZHZQ .

mcintyre321 commented 5 years ago

I've pushed a new version which I think should work. Heres a sample:

,new PropertyVm(typeof(object) , "Things")
                    {
                        DisplayName = "Pick a thing",
                        NotOptional =true,
                        Choices = new List<object>
                        {
                            new PropertyVm(typeof(string) , "ThingOne")
                            {
                                IsHidden = true,
                                DisplayName = "Thing One"
                            },
                            new PropertyVm(typeof(string) , "ThingTwo")
                            {
                                IsHidden = true,
                                DisplayName = "Thing Two"
                            },
                        }
                    }