0

I have a model, for example: "food". Each one of this has some basic info: "name" "calories", etc. I would like to provide a form where the user can add extra fields. For example, if the user is adding a new "food", beside the basic info he could also add new fields, like "sugar", "vitamins", etc.

How could I add the fields to the database so that it can be retrieved/queried later? Thanks!

Ruben
  • 23
  • 2

1 Answers1

0

Jacob Kaplan-Moss has an extensive writeup on dynamic form fields: http://jacobian.org/writing/dynamic-form-generation/

Essentially, you add more items to the form's fields member variable during instantiation.

Source

Even better.

Community
  • 1
  • 1
MD Islam
  • 137
  • 8