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 to add editable collection in Programatically created form? #84

Open
TonyWoo opened this issue May 29, 2019 · 4 comments
Open

How to add editable collection in Programatically created form? #84

TonyWoo opened this issue May 29, 2019 · 4 comments

Comments

@TonyWoo
Copy link

TonyWoo commented May 29, 2019

Thanks for provided so great library, just has a question, how to add editable collection in Programatically created form?

@mcintyre321
Copy link
Owner

Something like:

var formModel = new[]
            {
                    new PropertyVm(typeof(List<Movie>) , "movies")
                    {
                        DisplayName = "Movies",
                        NotOptional =true,
                        Value = new List<Movie>()
                        {
                             new Movie() {Title = "Fight Club"},
                             new Movie() {Title = "The Silent Partner" },
                             new Movie() {Title = "Bambi"},
                        }                        
                    },
};

...
 
    public class Movie
    {
        [Required]
        [StringLength(64, MinimumLength = 2)]
        public string Title { get; set; }
    }

@mcintyre321
Copy link
Owner

It's a bit more complex if you want to have a list of programatically created types, rather than a static type (like Movie).

@TonyWoo
Copy link
Author

TonyWoo commented May 29, 2019

Thanks for you quick reply @mcintyre321. I'd like build a form builder and user want to add some collection data. It seems the item type like Movie should be static type, not sure how to do it dynamically. thanks.

@mcintyre321
Copy link
Owner

Did the above work for you?

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

2 participants