angular2-easy-forms icon indicating copy to clipboard operation
angular2-easy-forms copied to clipboard

Nested Forms and Repeating Fields

Open enyachoke opened this issue 7 years ago • 5 comments

Do you plan on supporting question nesting and repeating questions.

enyachoke avatar Sep 17 '16 05:09 enyachoke

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?

flauc avatar Sep 17 '16 08:09 flauc

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'
    }]
  }
]

enyachoke avatar Sep 17 '16 09:09 enyachoke

Something on like a form with an address http://blog.thoughtram.io/angular/2016/06/22/model-driven-forms-in-angular-2.html

enyachoke avatar Sep 17 '16 09:09 enyachoke

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 👍

flauc avatar Sep 17 '16 09:09 flauc

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.

enyachoke avatar Sep 17 '16 10:09 enyachoke