Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formsets by Ref #139

Open
bkotch opened this issue Dec 20, 2017 · 0 comments
Open

Formsets by Ref #139

bkotch opened this issue Dec 20, 2017 · 0 comments

Comments

@bkotch
Copy link

bkotch commented Dec 20, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant