Marionette Form Wrapper
npm install marionette-form-wrapperFormWrapper componentFormWrapper is to have a black box that validates views for us.FormWrapper works by taking a view (ItemView, CollectionView or CompositeView) as input, and giving back another view that you can then call render or show on.
- Backbone.Validation
- Backbone.Syphon
Backbone.Validation
Example
Template:
```
Model:
`
var Model = Backbone.Model.extend({
validation: {
firstName: {
rangeLength: [1, 28]
},
lastName: {
rangeLength: [1, 29]
}
}
});
`
Every childView needs to respect the rules mentioned for the ItemView.
In case you pass an ItemView:
`
var viewToValidate = new Marionette.ItemView.extend({
model: new Model()
});
var formWrapper = new FormWrapper({
contentView: viewToValidate
});
formWrapper.render();
`
- ### contentView (Object, default: undefined, required: true)
The instance of the view that you want to validate.
- ### noHtml5Validate (Boolean, default: true, required: false)novalidate
Adds the attribute to the form` element and prevent the validation of the new HTML5 input types.