django.forms.ChoiceField

Here are the examples of the python api django.forms.ChoiceField taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

137 Examples 7

Example 1

Project: treeio Source File: forms.py
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)

        self.fields['status'].queryset = Object.filter_permitted(
            user, ItemStatus.objects, mode='x')
        self.fields['location'].queryset = Object.filter_permitted(
            user, Location.objects, mode='x')

        self.fields['status'].label = _('Status')
        self.fields['location'].label = _('Location')

        self.fields['delete'] = forms.ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                              ('delete', _(
                                                                                  'Delete Completely')),
                                                                              ('trash', _('Move to Trash'))), required=False)

Example 2

Project: django-autoreports Source File: fields.py
    def change_widget_sigle(self, field, choices, widget):
        field_initial = field.initial and field.initial[0] or None
        field = forms.ChoiceField(label=field.label,
                                  choices=choices,
                                  help_text=field.help_text,
                                  initial=field_initial)
        if widget == 'single__radiobuttons':
            field.widget = forms.RadioSelect(choices=field.widget.choices)
        return field

Example 3

Project: oioioi Source File: controllers.py
Function: adjust_upload_form
    def adjust_upload_form(self, request, existing_problem, form):
        super(PAContestController, self).adjust_upload_form(request,
                existing_problem, form)
        initial = 'NONE'
        if existing_problem:
            try:
                initial = PAProblemInstanceData.objects.get(
                        problem_instance__problem=existing_problem).division
            except PAProblemInstanceData.DoesNotExist:
                pass

        form.fields['division'] = forms.ChoiceField(required=True,
                label=_("Division"), initial=initial,
                choices=[('A', _("A")), ('B', _("B")), ('NONE', _("None"))])

Example 4

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)
        self.fields['delete'] = forms.ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                              ('delete', _(
                                                                                  'Delete Completely')),
                                                                              ('trash', _('Move to Trash'))),
                                                  required=False)

Example 5

Project: portal Source File: forms.py
    def __init__(self, *args, **kwargs):
        self.community = kwargs.pop('community')
        super(TransferOwnershipForm, self).__init__(*args, **kwargs)
        members = self.community.members.all()
        members = members.exclude(pk=self.community.admin.pk)
        choices = [(member.id, str(member)) for member in members]
        self.fields['new_admin'] = forms.ChoiceField(
            choices=choices, label="New community admin")

        self.helper = SubmitCancelFormHelper(
            self, cancel_href="{% url 'user' user.username %}")

Example 6

Project: shuup Source File: product_list_modifiers.py
Function: get_fields
    def get_fields(self, request, category=None):
        if not category:
            return

        configuration = get_configuration(request.shop, category)

        min_price = configuration.get(self.range_min_key)
        max_price = configuration.get(self.range_max_key)
        range_size = configuration.get(self.range_size_key)
        if not (min_price and max_price and range_size):
            return

        choices = [(None, "-------")] + get_price_ranges(
            request.shop, min_price, max_price, range_size)
        return [
            ("price_range", forms.ChoiceField(required=False, choices=choices, label=_("Price"))),
        ]

Example 7

Project: treeio Source File: forms.py
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)

        self.fields['status'].queryset = Object.filter_permitted(user,
                                                                 SaleStatus.objects.filter(
                                                                     use_sales=True),
                                                                 mode='x')
        self.fields['status'].label = _("Status:")
        self.fields['delete'] = forms.ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                              ('delete', _(
                                                                                  'Delete Completely')),
                                                                              ('trash', _('Move to Trash'))), required=False)

        self.fields['assignedto'].queryset = User.objects
        self.fields['assignedto'].label = _("Assign To:")

Example 8

Project: baruwa Source File: forms.py
Function: init
    def __init__(self, request=None, *args, **kwargs):
        super(ListAddForm, self).__init__(*args, **kwargs)
        self.request = request
        if not request.user.is_superuser:
            addresses = request.session['user_filter']['addresses']
            load_addresses = [(address, address) for address in addresses]
            self.fields['to_address'] = forms.ChoiceField(
                choices=load_addresses)

Example 9

Project: django-mysql Source File: test_forms.py
    def test_validate_fail(self):
        field = SimpleSetField(
            forms.ChoiceField(choices=(('a', 'The letter A'),
                                       ('b', 'The letter B')))
        )
        with pytest.raises(exceptions.ValidationError) as excinfo:
            field.clean('a,c')
        assert (
            excinfo.value.messages[0] ==
            'Item "c" in the set did not validate: '
            'Select a valid choice. c is not one of the available choices.'
        )

Example 10

Project: shuup Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(ContactGroupBaseForm, self).__init__(*args, **kwargs)
        self.fields['price_display_mode'] = forms.ChoiceField(
            choices=_PRICE_DISPLAY_MODE_CHOICES,
            label=_("Price display mode"),
            initial=_get_price_display_mode(self.instance))

Example 11

Project: wagtail Source File: forms.py
    def create_dropdown_field(self, field, options):
        options['choices'] = map(
            lambda x: (x.strip(), x.strip()),
            field.choices.split(',')
        )
        return django.forms.ChoiceField(**options)

Example 12

Project: tendenci Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        user = kwargs.pop('user', None)
        super(DirectoryPricingForm, self).__init__(*args, **kwargs)
        if user and user.profile.is_superuser:
            self.fields['duration'] = forms.ChoiceField(initial=14, choices=ADMIN_DURATION_CHOICES)
        else:
            self.fields['duration'] = forms.ChoiceField(initial=14, choices=DURATION_CHOICES)

Example 13

Project: shuup Source File: forms.py
    def __init__(self, **kwargs):
        super(ShopWizardForm, self).__init__(**kwargs)
        locale = get_current_babel_locale()
        self.fields["prices_include_tax"].help_text = _(
            "Show storefront products with tax pre-calculated into the price. "
            "Note this behavior can be overridden for customer groups."
        )
        self.fields["currency"] = forms.ChoiceField(
            choices=sorted(locale.currencies.items()),
            required=True,
            label=_("Currency")
        )

Example 14

Project: treeio Source File: forms.py
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)
        self.fields['delete'] = forms.ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                              ('delete', _(
                                                                                  'Delete Completely')),
                                                                              ('trash', _('Move to Trash'))),
                                                  required=False)

        self.fields['category'].label = _("Category")
        self.fields['category'].queryset = Object.filter_permitted(
            user, Category.objects, mode='x')
        self.fields['category'].label = _("Add to Category:")

Example 15

Project: readthedocs.org Source File: forms.py
Function: build_upload_html_form
def build_upload_html_form(project):
    """Upload HTML form with list of versions to upload HTML for"""
    attrs = {
        'project': project,
    }
    active = project.versions.public()
    if active.exists():
        choices = []
        choices += [(version.slug, version.verbose_name) for version in active]
        attrs['version'] = forms.ChoiceField(
            label=_("Version of the project you are uploading HTML for"),
            choices=choices,
        )
    return type('UploadHTMLForm', (BaseUploadHTMLForm,), attrs)

Example 16

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)
        self.fields['delete'] = forms.ChoiceField(label=_("With selected"), choices=(('', '-----'),
                                                                                     ('delete', _(
                                                                                         'Delete Completely')),
                                                                                     ('trash', _('Move to Trash'))),
                                                  required=False)

Example 17

Project: shuup Source File: forms.py
Function: init
    def __init__(self, **kwargs):
        self.theme = kwargs.pop("theme")
        super(GenericThemeForm, self).__init__(**kwargs)
        if self.theme.stylesheets:
            self.fields["stylesheet"] = forms.ChoiceField(
                label=_("Stylesheets"), choices=self.theme.stylesheets,
                initial=self.theme.stylesheets[0], required=True)

        fields = self.theme.fields
        if hasattr(fields, "items"):  # Quacks like a dict; that's fine too
            fields = fields.items()
        for name, field in fields:
            self.fields[name] = deepcopy(field)
        self.initial.update(self.instance.get_settings())

Example 18

Project: foodnetwork Source File: fields.py
Function: init
    def __init__(self, *args, **kwargs):
        errors = self.default_error_messages.copy()
        if 'error_messages' in kwargs:
            errors.update(kwargs['error_messages'])
        
        fields = (
            forms.ChoiceField(choices=self.EXP_MONTH, error_messages={'invalid': errors['invalid_month']}),
            forms.ChoiceField(choices=self.EXP_YEAR, error_messages={'invalid': errors['invalid_year']}),
        )
        
        super(CreditCardExpiryField, self).__init__(fields, *args, **kwargs)
        self.widget = CreditCardExpiryWidget(widgets=[fields[0].widget, fields[1].widget])

Example 19

Project: vumi-go Source File: forms.py
Function: init
    def __init__(self, user_api, *args, **kwargs):
        super(NewRouterForm, self).__init__(*args, **kwargs)
        routers = (v for k, v in sorted(user_api.router_types().iteritems()))
        type_choices = [(router['namespace'], router['display_name'])
                        for router in routers]
        self.fields['router_type'] = forms.ChoiceField(
            label="Which kind of router would you like?",
            choices=type_choices)

Example 20

Project: django-mysql Source File: test_forms.py
    def test_validate_fail(self):
        field = SimpleListField(
            forms.ChoiceField(choices=(('a', 'The letter A'),
                                       ('b', 'The letter B')))
        )
        with pytest.raises(exceptions.ValidationError) as excinfo:
            field.clean('a,c')
        assert (
            excinfo.value.messages[0] ==
            'Item 2 in the list did not validate: '
            'Select a valid choice. c is not one of the available choices.'
        )

Example 21

Project: django-paypal Source File: fields.py
Function: init
    def __init__(self, *args, **kwargs):
        errors = self.default_error_messages.copy()
        if 'error_messages' in kwargs:
            errors.update(kwargs['error_messages'])

        fields = (
            forms.ChoiceField(choices=self.EXP_MONTH, error_messages={'invalid': errors['invalid_month']}),
            forms.ChoiceField(choices=self.EXP_YEAR, error_messages={'invalid': errors['invalid_year']}),
        )

        super(CreditCardExpiryField, self).__init__(fields, *args, **kwargs)
        self.widget = CreditCardExpiryWidget(widgets=[fields[0].widget, fields[1].widget])

Example 22

Project: xadmin Source File: dashboard.py
Function: formfield_for_dbfield
    def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name == 'widget_type':
            widgets = widget_manager.get_widgets(self.request.GET.get('page_id', ''))
            form_widget = WidgetTypeSelect(widgets)
            return forms.ChoiceField(choices=[(w.widget_type, w.description) for w in widgets],
                                     widget=form_widget, label=_('Widget Type'))
        if 'page_id' in self.request.GET and db_field.name == 'page_id':
            kwargs['widget'] = forms.HiddenInput
        field = super(
            UserWidgetAdmin, self).formfield_for_dbfield(db_field, **kwargs)
        return field

Example 23

Project: qualitio Source File: filter.py
Function: init
    def __init__(self, *args, **kwargs):
        self.control_field_name = kwargs.pop('control_field_name', self.__class__.control_field_name)
        field = forms.ChoiceField(choices=kwargs.pop('choices', ()))
        self.base_fields[self.control_field_name] = field
        field.widget.attrs['class'] = 'control-select'
        field.label = ''
        super(SelectControlForm, self).__init__(*args, **kwargs)

Example 24

Project: portal Source File: test_forms.py
    def test_transfer_ownership_form(self):
        """Test transferring ownership form"""
        form = TransferOwnershipForm(community=self.community)
        self.assertIsInstance(form.fields['new_admin'], forms.ChoiceField)
        self.assertSequenceEqual(form.fields['new_admin'].choices, [])

        bar_user = User.objects.create_user(username="bar", password="foobar")
        bar_systers_user = SystersUser.objects.get(user=bar_user)
        self.community.add_member(bar_systers_user)

        User.objects.create_user(username="new", password="foobar")

        form = TransferOwnershipForm(community=self.community)
        self.assertSequenceEqual(form.fields['new_admin'].choices,
                                 [(bar_user.id, "bar")])

Example 25

Project: shuup Source File: forms.py
Function: init
    def __init__(self, **kwargs):
        self.request = kwargs.pop("request")
        self.instance = kwargs.get("instance")
        selected_provider = self.get_service_provider(self.request.GET.get("provider"))
        if selected_provider:
            self.service_provider = selected_provider
        super(BaseMethodForm, self).__init__(**kwargs)
        self.fields["choice_identifier"] = forms.ChoiceField(
            choices=_get_service_choices(self.service_provider),
            required=bool(self.service_provider),
            label=_("Service"),
        )
        self.fields[self.service_provider_attr].required = True

Example 26

Project: hubplus Source File: forms.py
    def __init__(self, *args, **kwargs):
        target = kwargs.pop('target')
        size = kwargs.pop('size', 80)
        super(PrimaryAvatarForm, self).__init__(*args, **kwargs)

        avatars = get_avatars_for(target)
        self.fields['choice'] = forms.ChoiceField(
            choices=[(c.id, avatar_img(c, size)) for c in avatars],
            widget=widgets.RadioSelect)

Example 27

Project: tendenci Source File: forms.py
    def __init__(self, *args, **kwargs):
        if 'user' in kwargs:
            self.user = kwargs.pop('user', None)
        else:
            self.user = None
        super(DonationAdminForm, self).__init__(*args, **kwargs)

        preset_amount_str = (get_setting('module', 'donations', 'donationspresetamounts')).strip('')
        if preset_amount_str:
            self.fields['donation_amount'] = forms.ChoiceField(choices=get_preset_amount_choices(preset_amount_str))

Example 28

Project: shuup Source File: forms.py
    def __init__(self, **kwargs):
        super(ShopBaseForm, self).__init__(**kwargs)
        self.fields["logo"].widget = MediaChoiceWidget(clearable=True)
        locale = get_current_babel_locale()
        self.fields["currency"] = forms.ChoiceField(
            choices=sorted(locale.currencies.items()),
            required=True,
            label=_("Currency")
        )
        self.disable_protected_fields()

Example 29

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)
        self.fields['delete'] = forms.ChoiceField(label=_("With selected"),
                                                  choices=(('', '-----'), ('delete', _('Delete Completely')),
                                                           ('trash', _('Move to Trash'))), required=False)

Example 30

Project: redsolution-cms Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(FrontpageForm, self).__init__(*args, **kwargs)
        self.fields['frontpage'] = forms.ChoiceField(
            label=_('Choose frontpage handler'),
            choices=self.get_fronpage_handlers(),
        )

Example 31

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)
        self.fields['delete'] = ChoiceField(label=_("With selected"), choices=(('', '-----'),
                                                                               ('delete', _(
                                                                                   'Delete Completely')),
                                                                               ('trash', _('Move to Trash'))),
                                            required=False)

Example 32

Project: shuup Source File: _basket.py
Function: init
    def __init__(self, *args, **kwargs):
        super(BasketCampaignForm, self).__init__(*args, **kwargs)

        coupon_code_choices = [('', '')] + list(
            Coupon.objects.filter(
                Q(active=True),
                Q(campaign=None) | Q(campaign=self.instance)
            ).values_list("pk", "code")
        )
        field_kwargs = dict(choices=coupon_code_choices, required=False)
        field_kwargs["help_text"] = _("Define the required coupon for this campaign.")
        field_kwargs["label"] = _("Coupon")
        if self.instance.pk and self.instance.coupon:
            field_kwargs["initial"] = self.instance.coupon.pk

        self.fields["coupon"] = forms.ChoiceField(**field_kwargs)

Example 33

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)

        self.fields['delete'] = forms.ChoiceField(label=_("With selected"),
                                                  choices=(('', '-----'), ('delete', _('Delete Completely')),
                                                           ('trash', _('Move to Trash'))), required=False)

Example 34

Project: vumi-go Source File: forms.py
Function: init
    def __init__(self, user_api, *args, **kwargs):
        super(NewConversationForm, self).__init__(*args, **kwargs)
        apps = (v for k, v in sorted(user_api.applications().iteritems()))
        type_choices = [(app['namespace'], app['display_name'])
                        for app in apps]
        self.fields['conversation_type'] = forms.ChoiceField(
            label="Which kind of conversation would you like?",
            choices=type_choices)

Example 35

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        if 'instance' in kwargs:
            self.instance = kwargs['instance']
            del kwargs['instance']

        super(MassActionForm, self).__init__(*args, **kwargs)
        self.fields['delete'] = ChoiceField(label=_("Delete"), choices=(('', '-----'),
                                                                        ('delete', _(
                                                                            'Delete Completely')),
                                                                        ('trash', _('Move to Trash'))), required=False)

Example 36

Project: shuup Source File: views.py
Function: get_form
    def _get_form(self, selected):
        form = self.form_class(**self.get_form_kwargs())
        report_field = forms.ChoiceField(
            choices=self._get_choices(),
            label=_("Type"),
            required=True,
            initial=selected.identifier,
        )
        form.fields["report"] = report_field
        return form

Example 37

Project: treeio Source File: forms.py
Function: init
    def __init__(self, user, *args, **kwargs):
        object_types = kwargs.pop('object_types')
        object_names = kwargs.pop('object_names')

        x = ((object_types[i], object_names[i])
             for i in range(0, len(object_types)))

        super(ObjChoiceForm, self).__init__(*args, **kwargs)
        self.fields['choice'] = forms.ChoiceField(
            label=_("Choose an Object to Report on"), choices=(x))

Example 38

Project: coursys Source File: select.py
Function: make_entry_field
    def make_entry_field(self, fieldsubmission=None):
        the_choices = [(k, v) for k, v in self.config.iteritems() if k.startswith("choice_") and self.config[k]]
        the_choices = sorted(the_choices, key=lambda choice: (int) (re.findall(r'\d+', choice[0])[0]))

        c = forms.ChoiceField(required=self.config['required'],
            label=self.config['label'],
            help_text=self.config['help_text'],
            choices=the_choices)

        if fieldsubmission:
            initial=fieldsubmission.data['info']
            c.initial=initial


        if not self.config['required']:
            c.choices.insert(0, ('', u'\u2014'))

        return c

Example 39

Project: django-transadmin Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(TranslationForm, self).__init__(*args, **kwargs)
        self.fields['context'].required = False
        self.fields['comment'].required = False
        self.fields['trans'].required = False
        if LANGUAGES:
            self.fields['language'] = forms.ChoiceField(choices=LANGUAGES)
        if CONTEXTS:
            self.fields['context'] = forms.ChoiceField(choices=CONTEXTS)

Example 40

Project: shuup Source File: forms.py
Function: populate
    def populate(self):
        """
        Populate the form with fields for size and plugin selection.
        """

        initial_cell_width = self.layout_cell.sizes.get("sm") or self.CELL_FULL_WIDTH

        self.fields["cell_width"] = forms.ChoiceField(
            label=_("Cell width"), choices=self.CELL_WIDTH_CHOICES, initial=initial_cell_width)

        self.fields["cell_align"] = forms.ChoiceField(
            label=_("Cell align"), choices=self.CELL_ALIGN_CHOICES, initial=" ")

        if self.theme:
            plugin_choices = self.theme.get_all_plugin_choices(empty_label=_("No Plugin"))
            plugin_field = self.fields["plugin"]
            plugin_field.choices = plugin_field.widget.choices = plugin_choices
            plugin_field.initial = self.layout_cell.plugin_identifier

Example 41

Project: django-radioportal Source File: forms.py
    def __init__(self, *args, **kwargs):
        super(EpisodePartForm, self).__init__(*args, **kwargs)
        if 'instance' in kwargs and kwargs['instance'].episode.show.shownotes_id:
            url = "https://shownot.es/api/podcasts/%s/" % kwargs['instance'].episode.show.shownotes_id
            result = requests.get(url).json()
            choices = sorted(result['episodes'], key=lambda x: x['create_date'], reverse=True)
            choices = filter(lambda x: x and "docuement" in x and x["docuement"] and "name" in x["docuement"] and x["docuement"]["name"], choices)
            choices = map(lambda x: (x['docuement']['name'], x['docuement']['name']), choices)
            choices.insert(0, (None, ''))
            self.fields["shownotes_id"] = forms.ChoiceField(choices=choices, required=False)

Example 42

Project: vumi-go Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(TagPoolForm, self).__init__(*args, **kwargs)
        name_choices = [('', '---------')]
        with closing(vumi_api()) as api:
            for pool_name in api.tpm.list_pools():
                name_choices.append((pool_name, pool_name))
        self.fields['name'] = forms.ChoiceField(choices=name_choices)

Example 43

Project: django-authorizenet Source File: fields.py
Function: init
    def __init__(self, *args, **kwargs):
        errors = self.default_error_messages.copy()
        if 'error_messages' in kwargs:
            errors.update(kwargs['error_messages'])

        fields = (
            forms.ChoiceField(
                choices=self.EXP_MONTH,
                error_messages={'invalid': errors['invalid_month']}),
            forms.ChoiceField(
                choices=self.EXP_YEAR,
                error_messages={'invalid': errors['invalid_year']}),
        )

        super(CreditCardExpiryField, self).__init__(fields, *args, **kwargs)
        self.widget = CreditCardExpiryWidget(widgets=[fields[0].widget,
                                                      fields[1].widget])

Example 44

Project: oioioi Source File: forms.py
Function: init
    def __init__(self, contest, existing_problem, *args, **kwargs):
        super(ProblemUploadForm, self).__init__(*args, **kwargs)
        self.round_id = None

        if contest and not existing_problem:
            choices = [(r.id, r.name) for r in contest.round_set.all()]
            if len(choices) >= 2:
                fields = self.fields.items()
                fields[0:0] = [('round_id', forms.ChoiceField(choices,
                        label=_("Round")))]
                self.fields = OrderedDict(fields)
            elif len(choices) == 1:
                self.round_id = choices[0][0]

Example 45

Project: baruwa Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(AdminListAddForm, self).__init__(*args, **kwargs)
        if not self.request.user.is_superuser:
            addresses = self.request.session['user_filter']['addresses']
            load_addresses = [(address, address) for address in addresses]
            self.fields['to_address'] = forms.ChoiceField(
            choices=load_addresses)
        else:
            self.fields['to_address'].widget = forms.TextInput(
            attrs={'size': '24'})

Example 46

Project: djangae Source File: fields.py
Function: init
    def __init__(self, fields=None, widget=None, choices=None, *args, **kwargs):
        fields = (
            forms.ChoiceField(),
            forms.CharField(max_length=30)
        )

        super(GenericRelationFormfield, self).__init__(fields=fields, widget=GenericRelationWidget(), *args, **kwargs)
        self.widget.widgets[0].choices = self.fields[0].choices = choices or get_all_model_choices()

Example 47

Project: vumi-go Source File: forms.py
Function: init
    def __init__(self, *args, **kw):
        groups = kw.pop('groups')
        super(SelectContactGroupForm, self).__init__(*args, **kw)
        self.fields['contact_group'] = forms.ChoiceField(
            label="Select group to store contacts in.",
            help_text="Or provide a name for a new group below.",
            choices=[(g.key, g.name) for g in groups])

Example 48

Project: rapidpro Source File: views.py
Function: init
    def __init__(self, *args, **kwargs):
        org = kwargs.pop('org')
        self.user = kwargs.pop('user')

        super(BaseActionForm, self).__init__(*args, **kwargs)

        objects_qs = getattr(self.model, self.model_manager).filter(org=org)
        if self.has_is_active:
            objects_qs = objects_qs.filter(is_active=True)

        self.fields['action'] = forms.ChoiceField(choices=self.allowed_actions)
        self.fields['objects'] = forms.ModelMultipleChoiceField(objects_qs)
        self.fields['add'] = forms.BooleanField(required=False)
        self.fields['number'] = forms.BooleanField(required=False)

        if self.label_model:
            label_qs = getattr(self.label_model, self.label_model_manager).filter(org=org)
            self.fields['label'] = forms.ModelChoiceField(label_qs, required=False)

Example 49

Project: shuup Source File: _edit.py
Function: get_form
    def _get_form(self, form_infos, selected, type_enabled):
        form = self.form_class(**self.get_form_kwargs())
        type_field = forms.ChoiceField(
            choices=form_infos.get_type_choices(),
            label=_("Type"),
            required=type_enabled,
            initial=selected.choice_value,
        )
        if not type_enabled:
            type_field.widget.attrs['disabled'] = True
        form.fields["type"] = type_field
        return form

Example 50

Project: tendenci Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(MarketingStepFourForm, self).__init__(*args, **kwargs)
        self.fields['sla'].required = True

        self.fields['send_to_email2'] = forms.ChoiceField(
            choices=(
                (True, _('Yes')),
                (False, _('No')),
                ),
            label=_('include emal2'))
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3