'Init the form.
We are adding fields here and not declaratively because the
form fields to include depend on the selected product/category.'

def __init__(self, product=None, category=None, *args, **kwargs):

    super(EditQuestionForm, self).__init__(*args, **kwargs)
    extra_fields = []
    if product:
        extra_fields += product.get('extra_fields', [])
    if category:
        extra_fields += category.get('extra_fields', [])
    error_messages = {'required': MSG_TITLE_REQUIRED, 'min_length': MSG_TITLE_SHORT, 'max_length': MSG_TITLE_LONG}
    field = StrippedCharField(label=TITLE_LABEL, min_length=5, max_length=160, widget=forms.TextInput(), error_messages=error_messages)
    self.fields['title'] = field
    error_messages = {'required': MSG_CONTENT_REQUIRED, 'min_length': MSG_CONTENT_SHORT, 'max_length': MSG_CONTENT_LONG}
    field = StrippedCharField(label=CONTENT_LABEL, min_length=5, max_length=10000, widget=forms.Textarea(), error_messages=error_messages)
    self.fields['content'] = field
    if ('sites_affected' in extra_fields):
        field = StrippedCharField(label=SITE_AFFECTED_LABEL, initial='http://', required=False, max_length=255, widget=forms.TextInput())
        self.fields['sites_affected'] = field
    if ('crash_id' in extra_fields):
        field = StrippedCharField(label=CRASH_ID_LABEL, help_text=CRASH_ID_HELP, required=False, max_length=255, widget=forms.TextInput())
        self.fields['crash_id'] = field
    if ('frequency' in extra_fields):
        field = forms.ChoiceField(label=FREQUENCY_LABEL, choices=FREQUENCY_CHOICES, required=False)
        self.fields['frequency'] = field
    if ('started' in extra_fields):
        field = StrippedCharField(label=STARTED_LABEL, required=False, max_length=255, widget=forms.TextInput())
        self.fields['started'] = field
    if ('addon' in extra_fields):
        field = StrippedCharField(label=ADDON_LABEL, required=False, max_length=255, widget=forms.TextInput())
        self.fields['addon'] = field
    if ('troubleshooting' in extra_fields):
        widget = forms.Textarea(attrs={'class': 'troubleshooting'})
        field = StrippedCharField(label=TROUBLESHOOTING_LABEL, help_text=TROUBLESHOOTING_HELP, required=False, max_length=655360, widget=widget)
        self.fields['troubleshooting'] = field
    if ('ff_version' in extra_fields):
        self.fields['ff_version'] = StrippedCharField(label=FF_VERSION_LABEL, required=False)
    if ('device' in extra_fields):
        self.fields['device'] = StrippedCharField(label=DEVICE_LABEL, required=False)
    if ('os' in extra_fields):
        self.fields['os'] = StrippedCharField(label=OS_LABEL, required=False)
    if ('plugins' in extra_fields):
        widget = forms.Textarea(attrs={'class': 'plugins'})
        self.fields['plugins'] = StrippedCharField(label=PLUGINS_LABEL, required=False, widget=widget)
