Hello. I am new to openedx tutor and I am trying to extend the registration page. I have created a custom django form.
This is a sample of my form.
class ExtraFieldForm(forms.ModelForm):
streams = forms.ModelMultipleChoiceField(
queryset=Streams.objects.all(),
widget=forms.ChoiceField(),
required=True,
)
class Meta:
model = UserProfile
fields = (
'phone_number',
'streams'
)
labels = {
'streams': _("Streams"),
}
help_text = {
'Streams': _("Please select your Streams"),
}
def __init__(self, *args, **kwargs):
super(ExtraFieldForm, self).__init__(*args, **kwargs)
self.fields['streams'].required = True
If I remove the streams from fields, the form is being rendered for the normal Fields (CharField, IntegerField). However, I am unable to render the streams field as a multiple select field.
Field Type Mapping line 187
There is this mapping which only has certain mappings.
FIELD_TYPE_MAP = {
forms.CharField: "text",
forms.PasswordInput: "password",
forms.ChoiceField: "select",
forms.TypedChoiceField: "select",
forms.Textarea: "textarea",
forms.BooleanField: "checkbox",
forms.EmailField: "email",
}
How can I implement the multiple select field in Tutor Nutmeg? Any help will be appreciated. Thanks