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

custom ModelMultipleChoiceField, initial values #137

Open
benzkji opened this issue Aug 7, 2014 · 4 comments
Open

custom ModelMultipleChoiceField, initial values #137

benzkji opened this issue Aug 7, 2014 · 4 comments

Comments

@benzkji
Copy link

benzkji commented Aug 7, 2014

I've developed a new custom field, a custom multiple select. I guess it should be added to this tuple:

MULTIPLE = (CHECKBOX_MULTIPLE, SELECT_MULTIPLE)

otherwise, initial values don't seem to be calculated correctly (I have {{request.GET.offer}}, when passing offer=60, it populates with 60 and 6...).

what would be the proper way to add my field to the MULTIPLE tuple?

@benzkji benzkji changed the title custom multiple field custom multiple field, initial values Aug 7, 2014
@benzkji
Copy link
Author

benzkji commented Aug 11, 2014

couldn't there be a check if the field inherits from a multiple base field, so the MULTIPLEwould be obsolete?

benzkji added a commit to benzkji/django-forms-builder that referenced this issue Aug 12, 2014
@stephenmcd
Copy link
Owner

Can you provide the code needed to reproduce your example?

@benzkji
Copy link
Author

benzkji commented Aug 14, 2014

the field (widget is not really interesting/important).

class OfferMultipleChoiceField(ModelMultipleChoiceField):
    widget = OfferWidget
    def __init__(self, *args, **kwargs):
        super(OfferMultipleChoiceField, self).__init__(queryset=OfferItem.objects.all(), *args, **kwargs)

point is, the model/modelmultiple only makes sense if one adds the queryset, so there normally is one field per model...probably why the modelmultiple is not at all in the available fields.

the error might only occur with modelmultiplechoicefields, I couldnt check this yet.

@benzkji benzkji changed the title custom multiple field, initial values custom ModelMultipleChoiceField, initial values Aug 14, 2014
@benzkji
Copy link
Author

benzkji commented Aug 14, 2014

adding forms.ModelMultipleChoiceField to *fields.MULTIPLE would help already, and then dealing with subclasses in the .is_a method even more.

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

2 participants