powmedia / backbone-forms

Form framework for BackboneJS with nested forms, editable lists and validation
MIT License
2.17k stars 413 forks source link

Should be able to define fieldsets on a Form subclass #260

Closed erikcw closed 11 years ago

erikcw commented 11 years ago

You should be able to define fieldsets (and the other options) by subclassing the form instead of just by passing options on initialization.

For example:

var UserForm = Backbone.Form.extend({
    template: _.template($('#formTemplate').html()),

    schema: {
        title:      { type: 'Select', options: ['Mr', 'Mrs', 'Ms'] },
        name:       'Text',
        email:      { validators: ['required', 'email'] },
        password:   'Password'
    },

    fieldsets: {
       {legend: "my fieldset", fields: ["title", "name", "email", "password"]}
    }
});

The fieldsets object will be ignored when building the form. Each of the constructor options should also be available for setting a subclass default.

powmedia commented 11 years ago

+1

On 7 Jul 2013, at 23:18, erikcw wrote:

You should be able to define fieldsets (and the other options) by subclassing the form instead of just by passing options on initialization.

For example:

var UserForm = Backbone.Form.extend({ template: _.template($('#formTemplate').html()),

schema: {
    title:      { type: 'Select', options: ['Mr', 'Mrs', 'Ms'] },
    name:       'Text',
    email:      { validators: ['required', 'email'] },
    password:   'Password'
},

fieldsets: {
   {legend: "my fieldset", fields: ["title", "name", "email", "password"]}
}

}); The fieldsets object will be ignored when building the form. Each of the constructor options should also be available for setting a subclass default.

— Reply to this email directly or view it on GitHub.

philfreo commented 11 years ago

Duplicate of #226