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 create list control programatically? #88

Open sahinaydin opened 4 years ago

sahinaydin commented 4 years ago

Hello. I would like to create list control programatically. There exist an example about List Rendering on the web page but I could not create this control programatically. Could you help about this matter?

mcintyre321 commented 4 years ago
var formModel = new[]
            {
                    new PropertyVm(typeof(IEnumerable<string>) , "RestrictedMaterials")
                    {
                        DisplayName = "RestrictedMaterials",
                        Choices = new[] { "Guns", "Knives", "Explosives", "Nuclear Waste", "Weaponised Viruses" },
                        Value = new[] {"Guns", "Explosives"} ,
                        Readonly = false ,

                    },
};

FF.PropertiesFor(formModel).Render().Dump();

I think it should be something like that.

sahinaydin commented 4 years ago

Thank you very much. It's worked.