我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用django.forms.MultipleHiddenInput()。
def get_form(self): """ Provide a standard bulk delete form if none has been specified for the view """ class BulkDeleteForm(ConfirmationForm): pk = ModelMultipleChoiceField(queryset=self.cls.objects.all(), widget=MultipleHiddenInput) if self.form: return self.form return BulkDeleteForm # # Device/VirtualMachine components #
def choice_field(self, **kwargs): if self.hidden: kwargs['widget'] = forms.MultipleHiddenInput() return forms.ChoiceField(choices=self.choices, **kwargs)
def make_field(self, **kwargs): if self.choices: if self.hidden: kwargs['widget'] = forms.MultipleHiddenInput() field = self.choice_field(**kwargs) else: if self.hidden: kwargs['widget'] = forms.HiddenInput() field = self.field(**kwargs) field.group = self.group field.default_text = self.default_text return field
def get_context_data_edit(self, context): context = super(RoomStatus, self).get_context_data_edit(context) context['form'].fields['extra_columns'].widget = forms.MultipleHiddenInput() return context
def get_merge_form(self, request): class MergeForm(forms.Form): # same name as admin site uses for checkboxes to select items for actions _selected_action = forms.CharField(widget=forms.MultipleHiddenInput) mtype = forms.ModelChoiceField( self.get_queryset(request), label=self.model._meta.verbose_name, widget=self.get_merge_autowidget(), ) return MergeForm