insin / insin/newforms

Formsets by Ref

Open
#139 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
634
Forks
46
PR merge metrics
No merged PRs in 30d

Description

In your documentation, you show managing the formsets by storing the constructed form in the state.

http://newforms.readthedocs.io/en/latest/formsets.html?highlight=formset

```
var ArticleFormSet = forms.FormSet.extend({form: Article})
var BookFormSet = forms.FormSet.extend({form: Book})

var PublicationManager = React.createClass({
getInitialState: function() {
return {
articleFormset: new ArticleFormSet({prefix: 'articles'})
, bookFormset: new BookFormSet({prefix: 'books'})
}
},

// ...rendering implemented as normal...

onSubmit: function(e) {
e.preventDefault()
var articlesValid = this.state.articleFormset.validate()
var booksValid = this.state.bookFormset.validate()
if (articlesValid && booksValid) {
// Do something with cleanedData() on the formsets
}
}
})
```

Is there a way we can do it via ref so we can reference the formset later and just allow the formset to render when the props update?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.