angular2-easy-forms
angular2-easy-forms copied to clipboard
Nested Forms and Repeating Fields
Do you plan on supporting question nesting and repeating questions.
Hi @enyachoke, I'm planing on extending the repository quit a lot, but I'm not really sure what you mean by nesting questions.
Can you give me an example?
There are times you may have a model like this
questions: [{
type: "group",
key:"nested",
questions: [{
type: 'text',
key: 'firstName',
value: 'John Doe',
label: 'First Name',
validation: [{
type: 'required'
}, {
type: 'minLength',
value: 5,
message: 'Please enter a name longer then 5 characters'
}, {
type: 'pattern',
value: '^[a-zA-Z ]+$',
message: 'Only letters and spaces are allowed'
}]
}]
},
{
type: 'text',
key: 'firstName',
value: 'John Doe',
label: 'First Name',
validation: [{
type: 'required'
}, {
type: 'minLength',
value: 5,
message: 'Please enter a name longer then 5 characters'
}, {
type: 'pattern',
value: '^[a-zA-Z ]+$',
message: 'Only letters and spaces are allowed'
}]
}
]
Something on like a form with an address http://blog.thoughtram.io/angular/2016/06/22/model-driven-forms-in-angular-2.html
To be honest i haven't been following the progress of forms in angular 2 lately. I see what you're getting at, and I'm definitely going to implement grouping at some point, but I'm not sure when i'll have the time.
If you're interested please feel free to send a PM of any kind, even a small commits help a lot 👍
I have a custom schema and I made a very poor attempt at something like this https://github.com/enyachoke/angular2-formentry (a prototype really). What I like about your code is it is well organized and solves a validations headache I have been having. Am basing off your code and adding the features my use case needs that is groups and repeating groups. If I crack it I will send a pr for sure. Thanks.