def __init__(self, *args, **kwargs): if kwargs.get('instance'): initial = kwargs.setdefault('initial', {}) initial['airports'] = [ t.pk for t in kwargs['instance'].airport_set.all() ] ModelForm.__init__(self, *args, **kwargs)
def __init__(self, owner=None, *args, **kwargs): if kwargs.get('instance'): initial = kwargs.setdefault('initial', {}) owner_person = kwargs['instance'].owner() if owner_person is None: owner_person = owner if owner_person is not None: initial['owner_email'] = owner_person.email initial['owner_institute'] = owner_person.institute initial['owner_firstname'] = owner_person.first_name initial['owner_lastname'] = owner_person.last_name head_person = kwargs['instance'].head() if head_person is None: head_person = owner if head_person is not None: initial['head_email'] = head_person.email initial['head_institute'] = head_person.institute initial['head_firstname'] = head_person.first_name initial['head_lastname'] = head_person.last_name tech_person = kwargs['instance'].tech() if tech_person is not None: initial['tech_email'] = tech_person.email initial['tech_institute'] = tech_person.institute initial['tech_firstname'] = tech_person.first_name initial['tech_lastname'] = tech_person.last_name initial['end_date'] = date.today() + relativedelta(years=+3) ModelForm.__init__(self, *args, **kwargs) self.fields['owner_email'].disabled = True self.fields['owner_institute'].disabled = True self.fields['owner_firstname'].disabled = True self.fields['owner_lastname'].disabled = True
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['protected_class'] = ModelMultipleChoiceField( error_messages={'required': PROTECTED_CLASS_ERROR}, required=True, label="", queryset=ProtectedClass.objects.filter( protected_class__in=PROTECTED_CLASS_CHOICES).order_by( 'form_order'), widget=UsaCheckboxSelectMultiple( attrs={'aria-describedby': 'protected-class-help-text'}), ) self.fields['other_class'].help_text = _( 'Please describe "Other reason"') self.fields['other_class'].widget = TextInput( attrs={'class': 'usa-input word-count-10'}) self.question_groups = [ QuestionGroup( self, ('protected_class', ), group_name= _('Do you believe any of these personal characteristics influenced why you were treated this way?' ), help_text= _('Some civil rights laws protect people from discrimination, which include these protected classes. These are some of the most common classes that we see.' ), optional=False, ally_id="protected-class-help-text") ]
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['hatecrimes_trafficking'] = ModelMultipleChoiceField( queryset=HateCrimesandTrafficking.objects.filter( hatecrimes_trafficking_option__in= HATE_CRIMES_TRAFFICKING_CHOICES), widget=UsaCheckboxSelectMultiple( attrs={'aria-describedby': 'hatecrimes-help-text'}), required=False, label=_( 'Please select if any that apply to your situation (optional)') ) self.question_groups = [ QuestionGroup( self, ('hatecrimes_trafficking', ), group_name=_('Hate Crimes & Human Trafficking'), help_text= _('Hate crimes and human trafficking are considered criminal cases and go through a different process for investigation than other civil rights cases. If we determine your situation falls into these categories after submitting your concern, we will contact you with next steps.' ), optional=False, cls="text-bold", ally_id="hatecrimes-help-text") ]
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['protected_class'] = ModelMultipleChoiceField( error_messages={'required': PROTECTED_CLASS_ERROR}, required=True, label="", queryset=ProtectedClass.objects.filter(protected_class__in=PROTECTED_CLASS_CHOICES).order_by('form_order'), widget=UsaCheckboxSelectMultiple(attrs={ 'aria-describedby': 'protected-class-help-text' }), ) self.fields['other_class'].help_text = _('Please describe "Other reason"') self.fields['other_class'].widget = TextInput( attrs={'class': 'usa-input word-count-10'} ) self.question_groups = [ QuestionGroup( self, ('protected_class',), group_name=PROTECTED_CLASS_QUESTION, help_text=_('There are federal and state laws that protect people from discrimination based on their personal characteristics. Here is a list of the most common characteristics that are legally protected. Select any that apply to your incident.'), optional=False, ally_id="protected-class-help-text" ) ]
def __init__(self, content_type=None, object_pk=None, attribute_name=None, hidden=False, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.helper = FormHelper(self) self.helper.add_input( Submit('submit', 'Submit', css_class='btn-primary')) self.helper.form_id = "bibs-form" self.helper.form_class = "bibs-forms" self.helper.form_action = reverse('bibsonomy:savegetbibsonomyentry') self.fields["pages_start"].widget.attrs['class'] = "form-control" self.fields["pages_end"].widget.attrs['class'] = "form-control" self.fields['bibtex'].widget = HiddenInput() self.fields['content_type'].widget = HiddenInput() self.fields['attribute'].widget = HiddenInput() self.fields['object_id'].widget = HiddenInput() if content_type is not None: self.fields['content_type'].initial = content_type if object_pk is not None: self.fields['object_id'].initial = object_pk if attribute_name is not None: self.fields['attribute'].initial = attribute_name
def __init__ (self, *args, **kw): ModelForm.__init__ (self, *args, **kw) if self.instance and isinstance (self.instance, Prodopt): inst=self.instance dc=self.fields.get('defaultchoice') if trace: print inst.all_choices # option_id # dir (inst) if inst.pk and inst.all_choices().count(): dc.queryset = inst.all_choices() #Choice.objects.filter (id__in = inst.choices.values_list('id', flat=True))
def __init__(self, *args, **kw): ModelForm.__init__(self, *args, **kw) self.fields['remarks'].widget = Textarea(attrs={ 'cols': '20', 'rows': '3' }) self.fields['issue_date'].widget.attrs = {'class': 'vDateField'} self.fields['pay_date'].widget.attrs = {'class': 'vDateField'}
def __init__(self,*args,**kwargs): ModelForm.__init__(self,*args,**kwargs) #first argument, index is the position of the field you want it to come before self.fields.insert(6,'time_added',forms.TimeField(widget=JSDateTimePickerWidget(), input_formats=('%H:%M',), required=True)) if not self.instance.id: self.instance.date_added = utc.localize(datetime.datetime.today()) self.fields['time_added'].initial = self.instance.date_added.time()
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) if self.instance: instfields = self.instance._meta.get_all_field_names() for fldname in self.fields: if fldname in instfields: continue self.fields[fldname].initial = getattr(self.instance, fldname)
def __init__(self, *args, **kw): ModelForm.__init__(self, *args, **kw) if self.instance and isinstance(self.instance, Prodopt): inst = self.instance dc = self.fields.get('defaultchoice') if trace: print inst.all_choices # option_id # dir (inst) if inst.pk and inst.all_choices().count(): dc.queryset = inst.all_choices( ) #Choice.objects.filter (id__in = inst.choices.values_list('id', flat=True))
def __init__(self, division=None, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['municipio'].choices = cargar_municipio() if division: # Evalúa si se estableció el tipo de novedad a registrar de acuerdo a la división indicada, en caso # contrario muestra un listado con todos los tipos de procedimientos registrados self.fields['tipo_procedimiento'].choices = cargar_tipo_procedimiento(division)
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['violation_summary'].widget.attrs['class'] = 'usa-textarea word-count-500' self.label_suffix = '' self.fields['violation_summary'].label = SUMMARY_QUESTION self.fields['violation_summary'].widget.attrs['aria-describedby'] = 'details-help-text' self.fields['violation_summary'].help_text = _("Please include any details you have about time, location, or people involved with the event, names of witnesses or any materials that would support your description") self.fields['violation_summary'].error_messages = {'required': VIOLATION_SUMMARY_ERROR} self.fields['violation_summary'].required = True
def __init__(self, *args, **kwargs): ImageValidationMixin.__init__(self, *args, **kwargs) ModelForm.__init__(self, *args, **kwargs) self.helper = FormHelper(self) self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-2' self.helper.field_class = 'col-lg-10' self.helper.form_tag = False self.helper.form_method = 'post' self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', empty_permitted=False, instance=None): ModelForm.__init__(self, data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance) # override manually to disabled format_field = self.fields['format'] format_field.widget.attrs = {'disabled':'disabled'} format_field.required = False self.fields['format'] = format_field
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', empty_permitted=False, instance=None): ModelForm.__init__(self, data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance) # override manually role_field = self.fields['role'] role_field.required = False role_field.choices = [(u'', u'---------')] + [(r.id, str(r)) for r in Role.objects.filter(anon=True)] # limit anon choices self.fields['role'] = role_field
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', empty_permitted=False, instance=None): ModelForm.__init__(self, data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance) # override manually role_field = self.fields['role'] #role_field.required = True role_field.label = _(u'Workspace level role') role_field.help_text = _(u'This role will apply to every text in the workspace. To share only a (few) texts with this user, you can leave this blank and delegate roles on texts once the user is created.') self.fields['role'] = role_field
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', empty_permitted=False, instance=None): ModelForm.__init__(self, data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance) # override manually role_field = self.fields['role'] #role_field.required = True role_field.label = _(u'Text level role') role_field.help_text = _(u'This role will apply only to this text.') self.fields['role'] = role_field
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['assigned_section'] = ChoiceField(widget=ComplaintSelect( label='Section', attrs={'classes': 'text-uppercase'}), choices=SECTION_CHOICES, required=False) self.fields['status'] = ChoiceField( widget=ComplaintSelect(label='Status'), choices=STATUS_CHOICES, required=False)
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['last_incident_month'].label = _('Month') self.fields['last_incident_month'].error_messages = { 'required': _('Please enter a month.'), } self.fields['last_incident_day'].label = _('Day') self.fields['last_incident_year'].label = _('Year') self.fields['last_incident_year'].error_messages = { 'required': _('Please enter a year.'), }
def __init__(self, *args, **kwargs): if "instance" in kwargs: initial = kwargs.setdefault("initial", {}) initial["teams"] = [team.pk for team in kwargs["instance"].team_set.all()] ModelForm.__init__(self, *args, **kwargs) super(PersonForm, self).__init__(*args, **kwargs) for field in iter(self.fields): if field != "person_pic": self.fields[field].widget.attrs.update({"class": "form-control"})
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['last_incident_month'].label = DATE_QUESTIONS['last_incident_month'] self.fields['last_incident_month'].error_messages = { 'required': _('Please enter a month.'), } self.fields['last_incident_month'].required = True self.fields['last_incident_day'].label = DATE_QUESTIONS['last_incident_day'] self.fields['last_incident_year'].label = DATE_QUESTIONS['last_incident_year'] self.fields['last_incident_year'].error_messages = { 'required': _('Please enter a year.'), } self.fields['last_incident_year'].required = True
def __init__ (self, *args, **kw): ModelForm.__init__ (self, *args, **kw) #self.fields ['choices'].queryset = Choice.objects.published() # so only published appear in slider cf = self.fields.get ('choices', '') if cf: cf.queryset = Choice.objects.published() # so only published appear in slider if self.instance and isinstance (self.instance, Prodopt): inst=self.instance dc=self.fields.get('defaultchoice') if trace: print inst.all_choices # option_id # dir (inst) if inst.pk and inst.all_choices().count(): dc.queryset = inst.all_choices() #Choice.objects.filter (id__in = inst.choices.values_list('id', flat=True))
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) # self.instance = instance of MumbleServer, NOT a server instance if self.instance and self.instance.id: if self.instance.online: confstr = "" conf = self.instance.defaultconf for field in conf: confstr += "%s: %s\n" % (field, conf[field]) self.fields["defaultconf"].initial = confstr else: self.fields["defaultconf"].initial = _( "This server is currently offline.")
def __init__(self, *args, **kwargs): # Only in case we build the form from an instance # (otherwise, 'protected class' list should be empty) if kwargs.get('instance'): # We get the 'initial' keyword argument or initialize it # as a dict if it didn't exist. initial = kwargs.setdefault('initial', {}) # The widget for a ModelMultipleChoiceField expects # a list of primary key for the selected data. initial['protected_class'] = [ t.pk for t in kwargs['instance'].protected_class_set.all() ] ModelForm.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['primary_complaint'] = ChoiceField( choices=PRIMARY_COMPLAINT_CHOICES, widget=CrtPrimaryIssueRadioGroup(attrs={ 'choices_to_examples': PRIMARY_COMPLAINT_CHOICES_TO_EXAMPLES, 'choices_to_helptext': PRIMARY_COMPLAINT_CHOICES_TO_HELPTEXT, }), required=True, error_messages={ 'required': PRIMARY_COMPLAINT_ERROR }, label=PRIMARY_REASON_QUESTION, help_text=_('Select the reason that best describes your concern. Each reason lists examples of civil rights violations that may relate to your incident. In another section of this report, you will be able to describe your concern in your own words.'), )
def __init__(self, *args, **kw): ModelForm.__init__(self, *args, **kw) #self.fields ['choices'].queryset = Choice.objects.published() # so only published appear in slider cf = self.fields.get('choices', '') if cf: cf.queryset = Choice.objects.published( ) # so only published appear in slider if self.instance and isinstance(self.instance, Prodopt): inst = self.instance dc = self.fields.get('defaultchoice') if trace: print inst.all_choices # option_id # dir (inst) if inst.pk and inst.all_choices().count(): dc.queryset = inst.all_choices( ) #Choice.objects.filter (id__in = inst.choices.values_list('id', flat=True))
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) a11y = ContactA11y() self.label_suffix = '' self.fields['contact_first_name'].label = CONTACT_QUESTIONS['contact_first_name'] self.fields['contact_last_name'].label = CONTACT_QUESTIONS['contact_last_name'] self.fields['contact_email'].label = CONTACT_QUESTIONS['contact_email'] self.fields['contact_phone'].label = CONTACT_QUESTIONS['contact_phone'] self.fields['contact_address_line_1'].label = CONTACT_QUESTIONS['contact_address_line_1'] self.fields['contact_address_line_2'].label = CONTACT_QUESTIONS['contact_address_line_2'] self.fields['contact_city'].label = CONTACT_QUESTIONS['contact_city'] self.fields['contact_zip'].label = CONTACT_QUESTIONS['contact_zip'] self.fields['contact_state'] = ChoiceField( choices=(("", _(' - Select - ')), ) + STATES_AND_TERRITORIES, widget=Select(attrs={ 'class': 'usa-select' }), label=CONTACT_QUESTIONS['contact_state'], required=False, ) self.fields['servicemember'] = TypedChoiceField( error_messages={'required': SERVICEMEMBER_ERROR}, widget=UsaRadioSelect(), label=SERVICEMEMBER_QUESTION, help_text=_('If you’re reporting on behalf of someone else, please select their status.'), empty_value=None, choices=SERVICEMEMBER_CHOICES, ) self.question_groups = [ QuestionGroup( self, ('contact_first_name', 'contact_last_name'), group_name=_('Your name'), help_text=_('Leave the fields blank if you\'d like to file anonymously'), ally_id=a11y.name_id ), QuestionGroup( self, ('contact_email', 'contact_phone', 'contact_address_line_1', 'contact_address_line_2'), group_name=CONTACT_QUESTIONS['contact_title'], help_text=_('You are not required to provide contact information, but it will help us if we need to gather more information about the incident you are reporting or to respond to your submission'), ally_id=a11y.contact_info_id ) ]
def __init__(self, *args, **kwargs): instance = kwargs.get('instance', None) if instance: book = instance.book else: book = Word.objects.order_by('-create_dt')[0].book kwargs['initial'] = {'book': book} ModelForm.__init__(self, *args, **kwargs) queryset = Word.objects.filter(book=book) if instance: queryset = queryset.exclude(pk=instance.pk) self.fields['related'].queryset = queryset self.fields['synonym'].queryset = queryset self.fields['antonym'].queryset = queryset
def __init__(self, *args, **kwargs): # Only in case we build the form from an instance # (otherwise, 'groups' list should be empty) if 'instance' in kwargs: # We get the 'initial' keyword argument or initialize it # as a dict if it didn't exist. initial = kwargs.setdefault('initial', {}) # The widget for a ModelMultipleChoiceField expects # a list of primary key for the selected data. initial['groups'] = [grp.pk for grp in kwargs['instance'].wishlistgroup_set.all()] if 'group' in kwargs: initial = kwargs.setdefault('initial', {}) groups = initial.setdefault('groups', []) groups.append(kwargs['group'].pk) del kwargs['group'] user = kwargs.pop('user') ModelForm.__init__(self, *args, **kwargs) self.fields['groups'].queryset = WishlistGroup.get_groups_by_user(user=user)
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) errors = dict(WHERE_ERRORS) self.fields['location_name'].label = LOCATION_QUESTIONS['location_name'] self.fields['location_name'].help_text = _('Examples: Name of business, school, intersection, prison, polling place, website, etc.') self.fields['location_name'].error_messages = { 'required': errors['location_name'] } self.fields['location_name'].required = True self.fields['location_address_line_1'].label = LOCATION_QUESTIONS['location_address_line_1'] self.fields['location_address_line_2'].label = LOCATION_QUESTIONS['location_address_line_2'] self.fields['location_city_town'].label = LOCATION_QUESTIONS['location_city_town'] self.fields['location_city_town'].error_messages = { 'required': errors['location_city_town'] } self.fields['location_city_town'].required = True self.fields['location_state'] = ChoiceField( choices=_add_empty_choice(STATES_AND_TERRITORIES), widget=Select(attrs={ 'aria-describedby': 'location-help-text', 'class': 'usa-select' }), required=True, error_messages={ 'required': errors['location_state'] }, label=LOCATION_QUESTIONS['location_state'], help_text=_("Where did this happen?"), ) self.question_groups = [ QuestionGroup( self, ('location_name', 'location_address_line_1', 'location_address_line_2'), group_name=LOCATION_QUESTIONS['location_title'], help_text=_('Please be as specific as possible. We will handle this information with sensitivity.'), optional=False, ally_id='location-help-text' ), ]
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['primary_complaint'] = ChoiceField( choices=PRIMARY_COMPLAINT_CHOICES, widget=CrtRadioArea( attrs={ 'choices_to_examples': PRIMARY_COMPLAINT_CHOICES_TO_EXAMPLES, 'choices_to_helptext': PRIMARY_COMPLAINT_CHOICES_TO_HELPTEXT, }), required=True, error_messages={'required': PRIMARY_COMPLAINT_ERROR}, label= _('What is your primary reason for contacting the Civil Rights Division?' ), help_text= _('Please choose the option below that best fits your situation. The examples listed in each are only a sampling of related issues. You will have space to explain in detail later.' ), )
def __init__(self, *args, **kwargs): read_only = False if 'read_only' in kwargs: read_only = kwargs.pop('read_only') ModelForm.__init__(self, *args, **kwargs) self.helper = FormHelper(self) self.helper.form_tag = False for f in self.fields: if isinstance(self.Meta.model._meta.get_field(f), BooleanField): self.fields[f].widget = RadioSelect() if read_only: # Read only form - Code from django snippets: # "https://djangosnippets.org/snippets/3040/"# from django.utils.translation import ugettext as _ from django.forms.widgets import Select for f in self.fields: self.fields[f].label = _(self.fields[f].label) if isinstance(self.fields[f].widget, Select): self.fields[f].widget.attrs['disabled'] = 'disabled' else: self.fields[f].widget.attrs['readonly'] = 'readonly'
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', empty_permitted=False, instance=None): ModelForm.__init__(self, data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance) # override manually role_field = self.fields['role'] role_field.required = False role_field.choices = [(u'', u'---------')] + [ (r.id, str(r)) for r in Role.objects.filter(anon=True) ] # limit anon choices self.fields['role'] = role_field
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=ErrorList, label_suffix=':', empty_permitted=False, instance=None): ModelForm.__init__(self, data, files, auto_id, prefix, initial, error_class, label_suffix, empty_permitted, instance) # override manually role_field = self.fields['role'] #role_field.required = True role_field.label = _(u'Workspace level role') role_field.help_text = _( u'This role will apply to every text in the workspace. To share only a (few) texts with this user, you can leave this blank and delegate roles on texts once the user is created.' ) self.fields['role'] = role_field
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) a11y = ContactA11y() self.label_suffix = '' self.fields['contact_first_name'].label = _('First name') self.fields['contact_last_name'].label = _('Last name') self.fields['contact_email'].label = _('Email address') self.fields['contact_phone'].label = _('Phone number') self.fields['servicemember'] = TypedChoiceField( error_messages={'required': SERVICEMEMBER_ERROR}, widget=UsaRadioSelect(), label=_( 'Are you now or have ever been an active duty service member?' ), help_text= _('If you’re reporting on behalf of someone else, please select their status.' ), empty_value=None, choices=SERVICEMEMBER_CHOICES, ) self.question_groups = [ QuestionGroup( self, ('contact_first_name', 'contact_last_name'), group_name=_('Your name'), help_text=_( 'Leave the fields blank if you\'d like to file anonymously' ), ally_id=a11y.name_id), QuestionGroup( self, ('contact_email', 'contact_phone'), group_name=_('Contact information'), help_text= _('You are not required to provide contact information, but it will help us if we need to gather more information about the incident you are reporting or to respond to your submission' ), ally_id=a11y.contact_info_id) ]
def __init__(self, data=None, files=None, auto_id=None, prefix=None, initial=None, error_class=None, label_suffix=':', empty_permitted=False, instance=None): """ Constructor for AuthorForm Class """ ModelForm.__init__(self, data=None, files=None, auto_id=None, prefix=None, initial=None, error_class=None, label_suffix=':', empty_permitted=False, instance=None) self.base_fields['title'].choices = [(0, 'zero'), (1, 'one')]
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) errors = dict(WHERE_ERRORS) self.fields['location_name'].label = 'Location name' self.fields[ 'location_name'].help_text = 'Examples: Name of business, school, intersection, prison, polling place, website, etc.' self.fields['location_name'].error_messages = { 'required': errors['location_name'] } self.fields[ 'location_address_line_1'].label = 'Street address 1 (Optional)' self.fields[ 'location_address_line_2'].label = 'Street address 2 (Optional)' self.fields['location_city_town'].label = 'City/town' self.fields['location_city_town'].error_messages = { 'required': errors['location_city_town'] } self.fields['location_state'] = ChoiceField( choices=STATES_AND_TERRITORIES, widget=CrtDropdown, required=True, error_messages={'required': errors['location_state']}, label='State', help_text="Where did this happen?") self.fields['location_state'].widget.attrs['list'] = 'states' self.question_groups = [ QuestionGroup( self, ('location_name', 'location_address_line_1', 'location_address_line_2'), group_name=_('Where did this happen?'), help_text= _('Please be as specific as possible. We will handle this information with sensitivity.' ), optional=False, ally_id='location-help-text'), ]
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['assigned_section'] = MultipleChoiceField( choices=SECTION_CHOICES, widget=CrtMultiSelect(attrs={ 'classes': 'text-uppercase', 'name': 'assigned_section' }), required=False) self.fields['location_state'] = ChoiceField( choices=STATES_AND_TERRITORIES, widget=CrtDropdown(attrs={'name': 'location_state'}), required=False, ) self.fields['assigned_section'].label = _('View sections') self.fields['contact_first_name'].label = _('Contact first name') self.fields['contact_last_name'].label = _('Contact last name') self.fields['location_city_town'].label = _('Incident location city') self.fields['location_state'].label = _('Incident location state') self.fields['location_state'].widget.attrs['list'] = 'states'
def __init__(self, *args, **kw): ModelForm.__init__(self, *args, **kw) if kw.has_key('instance'): self.fields['padre'].queryset = Rol.objects.exclude(id=kw['instance'].id).order_by('descripcion')
def __init__(self, data=None, *args, **kwargs): if data=={}: data=None ModelForm.__init__(self, data, *args, **kwargs)
def __init__(self, post, questions): ModelForm.__init__(self, post) self.questions = questions
def __init__ (self, *args, **kw): ModelForm.__init__ (self, *args, **kw) self.fields ['choices'].queryset = Choice.objects.published() # so only published appear in slider
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields.pop('work') self.fields.pop('notwork')
def __init__ (self, *args, **kw): ModelForm.__init__ (self, *args, **kw) self.fields ['options'].queryset = Option.objects.published() # so only published appear in slider
def __init__(self, *args, **kwargs): ImageValidationMixin.__init__(self, *args, **kwargs) ModelForm.__init__(self, *args, **kwargs) self.helper = FormHelper(self) self.helper.form_class = 'form-horizontal' self.helper.form_tag = False
def __init__(self, data=None, files=None, auto_id=None, prefix=None, initial=None, error_class=None, label_suffix=':', empty_permitted=False, instance=None) : """ Constructor for AuthorForm Class """ ModelForm.__init__(self, data=None, files=None, auto_id=None, prefix=None, initial=None, error_class=None, label_suffix=':', empty_permitted=False, instance=None) self.base_fields['title'].choices = [(0,'zero'),(1,'one')]
def __init__(self, *args, **kwargs): ModelForm.__init__(self, *args, **kwargs) self.fields['patient_id'].widget = HiddenInput()
def __init__ (self, *a, **k): """ Invert fields order """ ModelForm.__init__ (self, *a, **k) self.fields = SortedDict(self.fields.items()[::-1])