def _get_field(self, question):
        """
        Create a form field based on a question.
        """
        
        # multiple choice field (select)
        if question.type == 'M':
            
            choices = [('','')] + [(c, c) for c in question.get_possible_answers()]
            return forms.ChoiceField(
                label=question.text,
                required=question.required,
                widget=forms.Select(attrs={'class':'select_choice_field'}),
                choices=choices)
                
        # multiple choice field (radio)
        if question.type == 'R':

            choices = [(c, c) for c in question.get_possible_answers()]
            return forms.ChoiceField(
                label=question.text,
                required=question.required,
                widget=forms.RadioSelect(attrs={'class':'radio_choice_field'}),
                choices=choices)
        
        # multiple choice field (checkbox)
        if question.type == 'C':
          
            choices = [(c, c) for c in question.get_possible_answers()]
            return forms.MultipleChoiceField(
                label=question.text,
                required=question.required,
                widget=forms.CheckboxSelectMultiple(attrs={'class':'checkbox_choice_field'}),
                choices=choices)
            
        # short text field
        elif question.type == 'S':
            
            return forms.CharField(
                label=question.text,
                required=question.required,
                widget=forms.TextInput(attrs={'class':'short_text_field'}))
            
        # long text field
        elif question.type == 'L':
            
            return forms.CharField(
                label=question.text,
                required=question.required,
                widget=forms.Textarea(attrs={'class':'long_text_field'}))
dataset/ETHPy150Open sunlightlabs/django-simplesurvey/simplesurvey/forms.py/SurveyForm._get_field/original