ModelFormOptions not automatically populated

Anonymous avatarAnonymous created an issue

It would be nice if the ModelFormMetaclass's ModelFormOptions object was populated with the 'fields' key in BetterModelForm.fieldsets.

Here's a copy of that class:

class ModelFormOptions(object):
    def __init__(self, options=None):
        self.model = getattr(options, 'model', None)
        self.fields = getattr(options, 'fields', None)
        self.exclude = getattr(options, 'exclude', None)

Currently the fields attribute does not receive a copy of the fields used in BetterModelForm.fieldsets.

If the BetterModelForm doesn't contain all the required fields, the form will not validate correctly.

The current work-around is to include all the fields in the fieldsets attribute in the fields attribute:

class SampleForm(BetterModelForm):
    fieldsets = (
       ('main', {
         'fields: ('field_a', 'field_b'),
       })
    )
    fields = ('field_a', 'field_b')

This isn't a big deal, but it would be nice if this was documented. Or, even better yet, if the fieldset fields would be copied into SampleForm.fields automatically.

Comments (2)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.