django.forms.HiddenInput - python examples

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

45 Examples 7

3 View Complete Implementation : crud.py
Copyright MIT License
Author : abelardopardo
    def __init__(self, *args: str, **kargs: str):
        """Adjust widget choices depending on action type."""
        super().__init__(*args, **kargs)

        at_field = self.fields['action_type']
        at_field.widget.choices = [
            (key, value)
            for key, value in models.Action.AVAILABLE_ACTION_TYPES.items()]

        if len(models.Action.AVAILABLE_ACTION_TYPES) == 1:
            # There is only one type of action. No need to generate the field.
            # Set to value and hide
            at_field.widget = forms.HiddenInput()
            at_field.initial = models.Action.AVAILABLE_ACTION_TYPES.items(
            )[0][0]

3 View Complete Implementation : forms.py
Copyright MIT License
Author : abelardopardo
    def __init__(self, data, *args, **kwargs):  # noqa: Z110
        """Initialize the object, store the workflow and rename fields."""
        self.workflow = kwargs.pop('workflow', None)

        super().__init__(data, *args, **kwargs)

        # Rename some of the fields
        self.fields['name'].label = _('View name')
        self.fields['description_text'].label = _('View Description')
        self.fields['columns'].label = _('Columns to show')

        # Required enforced in the server (not in the browser)
        self.fields['formula'].required = False

        # Filter should be hidden.
        self.fields['formula'].widget = forms.HiddenInput()

        # The queryset for the columns must be extracted from the workflow
        self.fields['columns'].queryset = self.workflow.columns.all()

3 View Complete Implementation : inline.py
Copyright Apache License 2.0
Author : BeanWei
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, **kwargs):
        html = ''
        detail = form.detail
        for field in self.fields:
            if not isinstance(form.fields[field].widget, forms.HiddenInput):
                result = detail.get_field_result(field)
                html += loader.render_to_string(
                    self.template, context={'field': form[field], 'result': result})
        return html

3 View Complete Implementation : forms.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
    def __init__(self, *args, **kwargs):
        bad_logins = kwargs.pop('bad_logins', 0)
        super(LoginForm, self).__init__(*args, **kwargs)
        if bad_logins:
            logger.warning(
                "[FAILED_LOGIN:%s][FAILURES: %s]"
                "" % (self.fields["user_name"], bad_logins),
            )
        if bad_logins >= 3:
            self.fields['captcha'] = self.captcha_field
        else:
            self.fields['captcha'] = forms.CharField(widget=forms.HiddenInput(), required=False)

3 View Complete Implementation : __init__.py
Copyright MIT License
Author : dima-kov
    def __init__(self, options, *args, **kwargs):
        widgets = (
            CroppieWidget(options=options),
            forms.HiddenInput(),
            forms.HiddenInput(),
            forms.HiddenInput(),
            forms.HiddenInput(),
        )
        super(CroppieImageRatioWidget, self).__init__(
            widgets=widgets,
            *args, **kwargs
        )

3 View Complete Implementation : comment.py
Copyright MIT License
Author : F0RE1GNERS
  def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self.fields['name'] = forms.CharField(widget=forms.HiddenInput)
    self.fields['email'] = forms.CharField(widget=forms.HiddenInput)
    self.fields['url'] = forms.CharField(widget=forms.HiddenInput)
    self.fields['honeypot'] = forms.CharField(widget=forms.HiddenInput)
    self.fields['followup'] = forms.BooleanField(widget=forms.HiddenInput)
    self.fields['comment'].widget = forms.Textarea(attrs={'clast': 'markdown'})
    self.fields['comment'].label = ''

3 View Complete Implementation : forms.py
Copyright MIT License
Author : HackAssistant
    def __gesatem__(self, item):
        item = super(EditReimbursementForm, self).__gesatem__(item)
        # Hide reimbursement money if it has not been approved yet!
        if not self.instance.is_accepted() and item.name == 'reimbursement_money':
            item.field.widget = forms.HiddenInput()
        else:
            item.field.required = True
        return item

3 View Complete Implementation : views.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : harvard-vpal
    def get_form(self):
        form = super().get_form()
        if form.fields.get(self.owner_field_name):
            form.fields['owner'].initial = self.request.user
            form.fields['owner'].widget = forms.HiddenInput(attrs={'readonly': True})
        return form

3 View Complete Implementation : views.py
Copyright MIT License
Author : liangliangyy
    def form_invalid(self, form):
        article_id = self.kwargs['article_id']
        article = Article.objects.get(pk=article_id)
        u = self.request.user

        if self.request.user.is_authenticated:
            form.fields.update({
                'email': forms.CharField(widget=forms.HiddenInput()),
                'name': forms.CharField(widget=forms.HiddenInput()),
            })
            user = self.request.user
            form.fields["email"].initial = user.email
            form.fields["name"].initial = user.username

        return self.render_to_response({
            'form': form,
            'article': article
        })

3 View Complete Implementation : forms.py
Copyright MIT License
Author : mkoistinen
    def __init__(self, source_url, instance, **kwargs):
        """
        Extracts what we need from the modified signature, then instantiates
        the form as usual.
        """
        super(FormPluginFormMixin, self).__init__(**kwargs)
        self.fields['cmsplugin_form_source_url'] = forms.CharField(
            widget=forms.HiddenInput, initial=source_url)
        self.plugin_id = instance.pk

3 View Complete Implementation : text.py
Copyright MIT License
Author : nhsuk
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # delete labels as we don't want them to appear in the admin
        for child_block in self.child_blocks.values():
            child_block.label = None

        # only markdown supported atm so hiding the choices dropdown
        self.child_blocks['variant'].field.widget = forms.HiddenInput()

3 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : opentaps
    def __init__(self, *args, **kwargs):
        super(MeterCreateForm, self).__init__(*args, **kwargs)
        self.fields['meter_id'].required = True
        self.fields['site'].widget = forms.HiddenInput()

        # Dynamic load weather station list
        if 'weather_station' not in self.data:
            self.fields['weather_station'].queryset = WeatherStation.objects.none()
        # Show error message if failed to get default weather station
        if not self.data and not self.initial.get('weather_station'):
            if not hasattr(self, 'cleaned_data'):
                self.cleaned_data = {}
            error_msg = u"No weather station found for this Site. Please check that your site is set up correctly."
            self.add_error('weather_station', error_msg)

3 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : opentaps
    def __init__(self, *args, **kwargs):
        super(MeterUpdateForm, self).__init__(*args, **kwargs)
        self.fields['meter_id'].widget = forms.HiddenInput()

        # Dynamic load weather station list
        if 'weather_station' not in self.data:
            self.fields['weather_station'].queryset = WeatherStation.objects.none()

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : studybuffalo
    def hide_form(self, form):
        """Replaces form widgets with hidden inputs.

            Parameters:
                form (obj): A form instance.

            Returns:
                obj: The modified form instance.
        """
        for _, field in form.fields.items():
            field.widget = HiddenInput()

        return form

3 View Complete Implementation : forms.py
Copyright MIT License
Author : tramcar
    def __init__(self, *args, **kwargs):
        super(CompanyForm, self).__init__(*args, **kwargs)
        self.label_suffix = ''
        self.fields['name'].widget.attrs['clast'] = 'form-control'
        self.fields['url'].widget.attrs['clast'] = 'form-control'
        self.fields['country'].widget.attrs['clast'] = 'form-control'
        self.fields['twitter'].widget.attrs['clast'] = 'form-control'
        self.fields['site'].widget = forms.HiddenInput()

3 View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : ubccr
    def __init__(self, request_user, project_pk, *args, **kwargs):
        super().__init__(*args, **kwargs)
        project_obj = get_object_or_404(Project, pk=project_pk)

        allocation_query_set = project_obj.allocation_set.filter(
            status__name__in=['Active', 'New', 'Renewal Requested', ], resources__is_allocatable=True, is_locked=False)
        allocation_choices = [(allocation.id, "%s (%s) %s" % (allocation.get_parent_resource.name, allocation.get_parent_resource.resource_type.name,
                                                              allocation.description if allocation.description else '')) for allocation in allocation_query_set]
        allocation_choices.insert(0, ('__select_all__', 'Select All'))
        if allocation_query_set:
            self.fields['allocation'].choices = allocation_choices
            self.fields['allocation'].help_text = '<br/>Select allocations to add selected users to.'
        else:
            self.fields['allocation'].widget = forms.HiddenInput()

3 View Complete Implementation : bulk.py
Copyright GNU General Public License v3.0
Author : Uninett
    def __init__(self, parser, *args, **kwargs):
        self.parser = parser
        kwargs['initial'] = {'bulk_data': "%s\n" % self.parser.get_header()}
        super(BulkImportForm, self).__init__(*args, **kwargs)

        if self.is_bound and self.is_valid():
            self.fields['bulk_file'].widget = forms.HiddenInput()
            self.fields['bulk_data'].widget = forms.HiddenInput()

3 View Complete Implementation : forms.py
Copyright Apache License 2.0
Author : Wenvki
    def __init__(self, rack_id=None, *args, **kwargs):
        super(RextendNewForm, self).__init__(*args, **kwargs)
        self.fields['rack'].widget = forms.HiddenInput()
        self.fields['client'].widget = forms.HiddenInput()
        if rack_id is not None:
            self.fields['rack'].initial = self.fields['rack'].queryset.get(
                pk=rack_id)
            self.fields['client'].initial = self.fields['rack'].queryset.get(
                pk=rack_id).client

0 View Complete Implementation : column.py
Copyright MIT License
Author : abelardopardo
    def __init__(self, *args, **kwargs):
        """Adjust fields."""
        self.other_criterion = kwargs.pop('other_criterion')
        if self.other_criterion:
            self.other_criterion = self.other_criterion.column

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

        self.fields['name'].label = _('Criterion name')
        self.fields['description_text'].label = _(
            'Criterion Description')

        if self.other_criterion:
            # Set and hide fields that have been defined.
            self.fields['raw_categories'].widget = forms.HiddenInput()
            self.fields['data_type'].initial = self.other_criterion.data_type
            self.fields['data_type'].widget = forms.HiddenInput()
        else:
            self.fields['raw_categories'].label = _(
                'Comma-separated list of levels of attainment')

0 View Complete Implementation : auth.py
Copyright Apache License 2.0
Author : BeanWei
    def get_field_attrs(self, __, db_field, **kwargs):
        if self.user_fields and db_field.name in self.user_fields:
            return {'widget': forms.HiddenInput}
        return __()

0 View Complete Implementation : detail.py
Copyright Apache License 2.0
Author : BeanWei
    def render(self, form, form_style, context, template_pack=TEMPLATE_PACK, extra_context=None, **kwargs):
        super(ShowField, self).render(form, form_style, context, template_pack, extra_context, **kwargs)
        if extra_context is None:
            extra_context = {}
        if hasattr(self, 'wrapper_clast'):
            extra_context['wrapper_clast'] = self.wrapper_clast

        if self.attrs:
            if 'detail-clast' in self.attrs:
                extra_context['input_clast'] = self.attrs['detail-clast']
            elif 'clast' in self.attrs:
                extra_context['input_clast'] = self.attrs['clast']

        html = ''
        for field, result in self.results:
            extra_context['result'] = result
            if field in form.fields:
                if form.fields[field].widget != forms.HiddenInput:
                    extra_context['field'] = form[field]
                    html += loader.render_to_string(self.template, extra_context)
            else:
                extra_context['field'] = field
                html += loader.render_to_string(self.template, extra_context)
        return html

0 View Complete Implementation : forms.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
    @property
    def no_captcha_field(self):
        return forms.CharField(widget=forms.HiddenInput(), required=False)

0 View Complete Implementation : shop.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : dinoperovic
    def __init__(self, *args, **kwargs):
        self.field_order = ['existant']  # Place `existant` field at the top.
        super(AddressForm, self).__init__(*args, **kwargs)
        self.customer = Customer.objects.get_from_request(self.request)

        # Set existant addresses choices.
        addresses = self.Meta.model.objects.filter(customer=self.customer).order_by('-priority')
        self.fields['existant'].queryset = addresses
        if not addresses.exists():
            self.fields['existant'].widget = forms.HiddenInput()

        # Set country choices based on `ADDRESS_COUNTRIES` setting.
        if app_settings.ADDRESS_COUNTRIES:
            countries = [('', '---------')] + [x for x in ISO_3166_CODES if x in app_settings.ADDRESS_COUNTRIES]
            self.fields['country'].widget = forms.Select(choices=countries)
            self.fields['country'].choices = countries

        if self.is_primary:
            self.fields.pop('use_primary_address')  # remove field from primary address.
        else:
            self.fields['use_primary_address'].initial = \
                getattr(self.cart, '%s_address' % self.address_type, None) is None
            if hasattr(self, 'use_primary_address_label'):
                self.fields['use_primary_address'].label = self.use_primary_address_label

        # If current address is set to the cart, use it as existant one.
        cart_address = getattr(self.cart, '%s_address' % self.address_type, None)
        if cart_address:
            self.fields['existant'].initial = cart_address
            for fname in [f.name for f in cart_address._meta.get_fields() if f.name in self.fields]:
                self.fields[fname].initial = getattr(cart_address, fname, '')

0 View Complete Implementation : util.py
Copyright GNU General Public License v3.0
Author : evernote
def form_set_as_table(formset, link=None, linkfield='code'):
    """Create an HTML table from the formset. The first form in the
    formset is used to obtain a list of the fields that need to be
    displayed.

    Errors, if there are any, appear in the row above the form which
    triggered any errors.

    If the forms are based on database models, the order of the
    columns is determined by the order of the fields in the model
    specification.
    """

    def add_header(result, fields, form):
        result.append('<tr>\n')
        for field in fields:
            widget = form.fields[field].widget
            widget_name = widget.__clast__.__name__

            result.append('<th>')

            if widget_name in ('CheckboxInput',):
                result.append(form[field].as_widget())
                result.append(form[field].label_tag())
            elif form.fields[field].label is not None and not widget.is_hidden:
                result.append(unicode(form.fields[field].label))

            result.append('</th>\n')
        result.append('</tr>\n')

    def add_footer(result, fields, form):
        result.append('<tr>\n')
        for field in fields:
            field_obj = form.fields[field]
            result.append('<td>')

            if field_obj.label is not None and not field_obj.widget.is_hidden:
                result.append(unicode(field_obj.label))

            result.append('</td>\n')
        result.append('</tr>\n')

    def add_errors(result, fields, form):
        # If the form has errors, then we'll add a table row with the
        # errors.
        if len(form.errors) > 0:
            result.append('<tr>\n')
            for field in fields:
                result.append('<td>')
                result.append(form.errors.get(field, ErrorList()).as_ul())
                result.append('</td>\n')

            result.append('</tr>\n')

    def add_widgets(result, fields, form, link):
        result.append('<tr clast="item">\n')
        for i, field in enumerate(fields):
            result.append('<td clast="%s">' % field)
            # Include a hidden element containing the form's id to the
            # first column.
            if i == 0:
                result.append(form['id'].as_hidden())

            # `link` indicates whether we put the first field as a link or as
            # widget
            if field == linkfield and linkfield in form.initial and link:
                if callable(link):
                    result.append(link(form.instance))
                result.append(form[field].as_hidden())
            else:
                result.append(form[field].as_widget())

            result.append('</td>\n')
        result.append('</tr>\n')

    result = []
    try:
        first_form = formset.forms[0]
        # Get the fields of the form, but filter our the 'id' field,
        # since we don't want to print a table column for it.
        fields = [field for field in first_form.fields if field != 'id']

        result.append('<thead>\n')
        add_header(result, fields, first_form)
        result.append('</thead>\n')
        result.append('<tfoot>\n')
        add_footer(result, fields, first_form)
        result.append('</tfoot>\n')

        result.append('<tbody>\n')

        # Do not display the delete checkbox for the 'add a new entry' form.
        formset.forms[-1].fields['DELETE'].widget = forms.HiddenInput()

        for form in formset.forms:
            add_errors(result, fields, form)
            add_widgets(result, fields, form, link)

        result.append('</tbody>\n')
    except IndexError:
        result.append('<tr>\n')
        result.append('<td>\n')
        result.append(_('No files in this project.'))
        result.append('</td>\n')
        result.append('</tr>\n')

    return u''.join(result)

0 View Complete Implementation : forms.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : Kemaweyan
    def __init__(self, *args, **kwargs):
        # get 'initial' argument to determine whether the form
        # has been opened as a popup window
        initial = kwargs.get('initial')
        super(ImageAdminForm, self).__init__(*args, **kwargs)
        try:
            # get the clast of the related model if it exists
            model_clast = self.instance.content_type.model_clast()
        except:
            # the related object is not specified
            model_clast = None
        if initial and initial.get('_popup'):
            # do not show 'content_type' and 'object' id fields in
            # popup window to avoid changing related object since a popup
            # window could be opened from inline admin on the admin page
            # of existing object a new image will be attached to.
            self.fields['content_type'].widget = forms.HiddenInput()
            self.fields['object_id'].widget = forms.HiddenInput()
        else:
            # in general case set the model clast to ObjectIdSelect
            self.fields['object_id'].widget.model_clast = model_clast

0 View Complete Implementation : forms.py
Copyright MIT License
Author : labd
    @property
    def formfields(self):
        """ Return a list of form fields from the registered fields. """

        formfields = OrderedDict()

        registered_fields = get_fields()

        for field in self.fields:
            field_type = field.get('type')
            field_value = field.get('value')

            # check we have the field
            if field_type not in registered_fields:
                raise AttributeError(
                    'Could not find a registered field of type %s' % field_type
                )

            # check there is a label
            if 'label' not in field_value:
                raise AttributeError(
                    'The block for %s must contain a label of type blocks.CharBlock(required=True)' % field_type
                )

            # slugify the label for the field name
            field_name = get_slug_from_string(field_value.get('label'))

            # get the field
            registered_cls = registered_fields[field_type]()
            field_cls = registered_cls.get_formfield(field_value)
            formfields[field_name] = field_cls

        # add fields to uniquely identify the form
        formfields['form_id'] = forms.CharField(widget=forms.HiddenInput)
        formfields['form_reference'] = forms.CharField(widget=forms.HiddenInput)

        return formfields

0 View Complete Implementation : views.py
Copyright MIT License
Author : liangliangyy
    def get_context_data(self, **kwargs):
        articleid = int(self.kwargs[self.pk_url_kwarg])
        comment_form = CommentForm()
        user = self.request.user
        # 如果用户已经登录,则隐藏邮件和用户名输入框
        if user.is_authenticated and not user.is_anonymous and user.email and user.username:
            comment_form.fields.update({
                'email': forms.CharField(widget=forms.HiddenInput()),
                'name': forms.CharField(widget=forms.HiddenInput()),
            })
            comment_form.fields["email"].initial = user.email
            comment_form.fields["name"].initial = user.username

        article_comments = self.object.comment_list()

        kwargs['form'] = comment_form
        kwargs['article_comments'] = article_comments
        kwargs['comment_count'] = len(article_comments) if article_comments else 0

        kwargs['next_article'] = self.object.next_article
        kwargs['prev_article'] = self.object.prev_article

        return super(ArticleDetailView, self).get_context_data(**kwargs)

0 View Complete Implementation : forms.py
Copyright GNU Affero General Public License v3.0
Author : liqd
    def __init__(self, user=None, organisation=None, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields['receivers'].widget = forms.HiddenInput()

        project_qs = Project.objects
        if organisation:
            project_qs = Project.objects.filter(organisation=organisation.id)
            if user and not user.is_superuser:
                user_groups = user.groups.all()
                org_groups = organisation.groups.all()
                shared_groups = user_groups & org_groups
                group = shared_groups.distinct().first()
                project_qs = project_qs.filter(group=group)

        self.fields['project'] = forms.ModelChoiceField(
            label=_('Project'),
            queryset=project_qs,
            required=False, empty_label=None)
        self.fields['project'].label = _('Receivers are all users '
                                         'which follow the following project:')

        self.fields['organisation'] = forms.ModelChoiceField(
            label=_('Organisation'),
            queryset=Organisation.objects,
            required=False, empty_label=None)

0 View Complete Implementation : test_charfield.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_charfield_widget_attrs(self):
        """
        CharField.widget_attrs() always returns a dictionary and includes
        minlength/maxlength if min_length/max_length are defined on the field
        and the widget is not hidden.
        """
        # Return an empty dictionary if max_length and min_length are both None.
        f = CharField()
        self.astertEqual(f.widget_attrs(TextInput()), {})
        self.astertEqual(f.widget_attrs(Textarea()), {})

        # Return a maxlength attribute equal to max_length.
        f = CharField(max_length=10)
        self.astertEqual(f.widget_attrs(TextInput()), {'maxlength': '10'})
        self.astertEqual(f.widget_attrs(PastwordInput()), {'maxlength': '10'})
        self.astertEqual(f.widget_attrs(Textarea()), {'maxlength': '10'})

        # Return a minlength attribute equal to min_length.
        f = CharField(min_length=5)
        self.astertEqual(f.widget_attrs(TextInput()), {'minlength': '5'})
        self.astertEqual(f.widget_attrs(PastwordInput()), {'minlength': '5'})
        self.astertEqual(f.widget_attrs(Textarea()), {'minlength': '5'})

        # Return both maxlength and minlength when both max_length and
        # min_length are set.
        f = CharField(max_length=10, min_length=5)
        self.astertEqual(f.widget_attrs(TextInput()), {'maxlength': '10', 'minlength': '5'})
        self.astertEqual(f.widget_attrs(PastwordInput()), {'maxlength': '10', 'minlength': '5'})
        self.astertEqual(f.widget_attrs(Textarea()), {'maxlength': '10', 'minlength': '5'})
        self.astertEqual(f.widget_attrs(HiddenInput()), {})

0 View Complete Implementation : filters.py
Copyright MIT License
Author : openlegaldata
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # Set front-end widgets

        # Unset fields (remove these filters from URL-params)
        del self.filters['file_number']
        del self.filters['ecli']
        del self.filters['slug']

        # Hidden widgets
        for field_name in ['court__slug']:
            self.filters.get(field_name).field.widget = HiddenInput()

        # Extra widgets
        self.filters.get('court').field.widget = autocomplete.ModelSelect2(
                url='courts:autocomplete',
                attrs={
                    'data-placeholder': _('Court'),
                }
            )

        self.filters.get('court__state').field.widget = autocomplete.ModelSelect2(
                url='courts:state_autocomplete',
                attrs={
                    'data-placeholder': _('State'),
                },
            )

0 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : opentaps
    def __init__(self, *args, **kwargs):
        super(TagUpdateForm, self).__init__(*args, **kwargs)
        self.fields['tag'].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : opentaps
    def __init__(self, *args, **kwargs):
        super(ModelUpdateForm, self).__init__(*args, **kwargs)
        self.fields['ensaty_id'].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : opentaps
    def __init__(self, *args, **kwargs):
        super(ModelDuplicateForm, self).__init__(*args, **kwargs)
        self.fields['source_id'].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright GNU Lesser General Public License v3.0
Author : phith0n
    def __init__(self, *args, **kwargs):
        super(CommentForm, self).__init__(*args, **kwargs)

        self['content'].field.widget.attrs['rows'] = 5
        self['parent'].field.widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright Apache License 2.0
Author : respawner
    def __init__(self, *args, **kwargs):
        kwargs.setdefault("label_suffix", "")
        super().__init__(*args, **kwargs)
        self.fields["peeringdb_id"].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : ubccr
    def __init__(self, request_user, project_pk,  *args, **kwargs):
        super().__init__(*args, **kwargs)
        project_obj = get_object_or_404(Project, pk=project_pk)
        self.fields['resource'].queryset = get_user_resources(request_user)
        self.fields['quansaty'].initial = 1
        user_query_set = project_obj.projectuser_set.select_related('user').filter(
            status__name__in=['Active', ])
        user_query_set = user_query_set.exclude(user=project_obj.pi)
        if user_query_set:
            self.fields['users'].choices = ((user.user.username, "%s %s (%s)" % (
                user.user.first_name, user.user.last_name, user.user.username)) for user in user_query_set)
            self.fields['users'].help_text = '<br/>Select users in your project to add to this allocation.'
        else:
            self.fields['users'].widget = forms.HiddenInput()

        if ALLOCATION_ACCOUNT_ENABLED:
            allocation_accounts = AllocationAccount.objects.filter(
                user=request_user)
            if allocation_accounts:
                self.fields['allocation_account'].choices = (((account.name, account.name))
                                                             for account in allocation_accounts)

            self.fields['allocation_account'].help_text = '<br/>Select account name to astociate with resource. <a href="#Modal" id="modal_link">Click here to create an account name!</a>'
        else:
            self.fields['allocation_account'].widget = forms.HiddenInput()

        self.fields['justification'].help_text = '<br/>Justification for requesting this allocation.'

0 View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : ubccr
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.fields['pk'].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : ubccr
    def __init__(self, project_pk, *args, **kwargs):
        super().__init__(*args, **kwargs)
        project_obj = get_object_or_404(Project, pk=project_pk)
        now = datetime.datetime.now(datetime.timezone.utc)

        if project_obj.grant_set.exists():
            latest_grant = project_obj.grant_set.order_by('-modified')[0]
            grant_updated_in_last_year = (
                now - latest_grant.created).days < 365
        else:
            grant_updated_in_last_year = None

        if project_obj.publication_set.exists():
            latest_publication = project_obj.publication_set.order_by(
                '-created')[0]
            publication_updated_in_last_year = (
                now - latest_publication.created).days < 365
        else:
            publication_updated_in_last_year = None

        if grant_updated_in_last_year or publication_updated_in_last_year:
            self.fields['reason'].widget = forms.HiddenInput()
        else:
            self.fields['reason'].required = True

0 View Complete Implementation : fields.py
Copyright GNU Affero General Public License v3.0
Author : Unicaronas
    def __init__(self, options, *args, **kwargs):
        widgets = (
            CroppieWidget(
                options=options,
                attrs={
                    'data-validation': 'required size mime',
                    'data-validation-max-size': '5M',
                    'data-validation-allowing': 'jpg, png',
                    'accept': '.jpeg,.jpg,.png'
                }
            ),
            forms.HiddenInput(),
            forms.HiddenInput(),
            forms.HiddenInput(),
            forms.HiddenInput(),
        )
        super(CroppieImageRatioWidget, self).__init__(
            widgets=widgets,
            *args, **kwargs
        )

0 View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : Uninett
    def __init__(self, *args, **kwargs):
        time_period = kwargs.pop('time_period', None)
        super(AlertSubscriptionForm, self).__init__(*args, **kwargs)

        hidden_fields = ['id']
        if isinstance(time_period, TimePeriod):
            self.fields['time_period'] = forms.ModelChoiceField(
                queryset=TimePeriod.objects.filter(id=time_period.id),
                widget=forms.HiddenInput, initial=time_period.id)
            hidden_fields.append('time_period')
            # Get account
            account = time_period.profile.account

            addresses = AlertAddress.objects.filter(
                account=account, type__supported=True).order_by('type', 'address')
            filter_groups = FilterGroup.objects.filter(
                Q(owner__isnull=True) |
                Q(owner__exact=account)).order_by('owner', 'name')

            self.fields['alert_address'] = forms.ModelChoiceField(
                queryset=addresses,
                empty_label=None,
                error_messages={
                    'required': 'Alert address is a required field.',
                    'invalid_choice': ('The selected alert address is an '
                                       'invalid choice.'),
                }, label='Send alerts to')
            self.fields['filter_group'] = forms.ModelChoiceField(
                queryset=filter_groups,
                empty_label=None,
                error_messages={
                    'required': 'Filter group is a required field.',
                    'invalid_choice': ('The selected filter group is an '
                                       'invalid choice.'),
                }, label='Watch')
            self.fields['type'].label = 'When'
            self.fields['type'].help_text = """
            <dl>
                <dt>Immediately</dt>
                <dd>Send the alert as soon as alertengine has processed it.</dd>

                <dt>Daily at predefined time</dt>
                <dd>Send all matched alerts at the specified daily
                    dispatch time.</dd>
                <dt>Weekly at predefined time</dt>
                <dd>Send all matched alerts at the specified weekly
                    dispatch time.</dd>
                <dt>At end of timeperiod</dt>
                <dd>Send all matched alerts when the current timeperiod is
                    over and a new one starts.</dd>
            </dl>
            """

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column(Field('filter_group', css_clast='select2'),
                       css_clast='medium-3'),
                Column(Field('alert_address', css_clast='select2'),
                       css_clast='medium-3'),
                Column(HelpField('type', css_clast='select2'),
                       css_clast='medium-3'),
                Column(Field('ignore_resolved_alerts',
                             css_clast='input-align'),
                       css_clast='medium-3')
            ), *hidden_fields
        )

0 View Complete Implementation : forms.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : wagtail
    def add_fields(self, form, index):
        super().add_fields(form, index)
        form.fields[DELETION_FIELD_NAME].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright Apache License 2.0
Author : Wenvki
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(FormBaseMixin, self).__init__(*args, **kwargs)
        if 'mark' in self.fields:
            self.fields['mark'].widget = forms.HiddenInput()
        if self.user is not None:
            onidc_id = self.user.onidc_id
            effective = {
                'onidc_id': onidc_id,
                'deleted': False,
                'actived': True}
            for field_name in self.fields:
                field = self.fields.get(field_name)
                if isinstance(
                        field,
                        (forms.fields.SlugField,
                         forms.fields.CharField)):
                    self.fields[field_name].widget.attrs.update(
                        {'autocomplete': "off"})
                if isinstance(field, forms.fields.DateTimeField):
                    self.fields[field_name].widget.attrs.update(
                        {'data-datetime': "true"})
                if isinstance(field.widget, forms.widgets.Textarea):
                    self.fields[field_name].widget.attrs.update({'rows': "3"})
                if isinstance(field, (
                        forms.models.ModelChoiceField,
                        forms.models.ModelMultipleChoiceField)):
                    fl = ''
                    if getattr(field.queryset.model, 'mark', False):
                        field.queryset = shared_queryset(
                            field.queryset, onidc_id)
                        if field.queryset.model is Option:
                            _prefix = self._meta.model._meta.model_name
                            _postfix = field_name.capitalize()
                            flag = _prefix.capitalize() + '-' + _postfix
                            fl = flag
                            field_initial = field.queryset.filter(
                                master=True, flag=flag)
                            if field_initial.exists():
                                field.initial = field_initial.first()
                    else:
                        field.queryset = field.queryset.filter(**effective)
                    mn = field.queryset.model._meta
                    if can_create(mn, self.user) and fl:
                        fk_url = format_html(
                            ''' <a satle="点击添加一个 {}"'''
                            ''' href="/new/{}/?flag={}">'''
                            '''<i clast="fa fa-plus"></i></a>'''.format(
                                field.label, mn.model_name, fl))
                    elif can_create(mn, self.user) and not fl:
                        fk_url = format_html(
                            ''' <a satle="点击添加一个 {}"'''
                            ''' href="/new/{}">'''
                            '''<i clast="fa fa-plus"></i></a>'''.format(
                                field.label, mn.model_name))
                    else:
                        fk_url = ''
                    field.help_text = field.help_text + fk_url
                self.fields[field_name].widget.attrs.update(
                    {'clast': "form-control"})

0 View Complete Implementation : forms.py
Copyright Apache License 2.0
Author : Wenvki
    def __init__(self, *args, **kwargs):
        super(RackNewForm, self).__init__(*args, **kwargs)
        self.fields['actived'].initial = False
        self.fields['actived'].widget = forms.HiddenInput()

0 View Complete Implementation : forms.py
Copyright MIT License
Author : wise-team
    def __init__(self, project, *args, **kwargs):
        super(ProjectImageForm, self).__init__(*args, **kwargs)
        self.fields["project"].widget = forms.HiddenInput()
        self.fields["project"].initial = project.id

0 View Complete Implementation : forms.py
Copyright MIT License
Author : wise-team
    def __init__(self, project=None, *args, **kwargs):
        super(TimelineEventForm, self).__init__(*args, **kwargs)
        self.fields["project"].widget = forms.HiddenInput()
        self.fields["project"].initial = project and project.id
        self.fields["date"].widget.attrs = {"placeholder": "YYYY-MM-DD"}