Reputation: 903
I'm using inline formset and I can't submit the form when one of the fields is hidden in template.
{{ form.provider.as_hidden }}
When the field is shown in the forms of the formset everything works normally. The field is properly populated and I can submit the form.
{{ form.provider }}
Any ideas what causes this issue?
forms.py
class DurationForm(forms.ModelForm):
class Meta:
model = Duration
fields = [
'provider',
'duration',
'price'
]
widgets={
"duration":forms.TextInput(attrs={'placeholder':'Duration'}),
"price":forms.TextInput(attrs={'placeholder':'Price'}),
#"provider":forms.HiddenInput(),
}
Upvotes: 2
Views: 452
Reputation: 28692
Per the docs, as_hidden
is only for bound fields and should be primarily used internally. You should try using a a HiddenInput
widget (or a MultipleHiddenInput
widget if that's more appropriate for your provider
field) and your form should work fine.
Upvotes: 1