python - django submit form on change -
hello trying submit form when selection option on choicefield
class actionform(forms.form): """ holds options mailbox management """ choices = ['create new folder', 'delete', 'read', 'unread'] action = forms.choicefield(choices=choices, attrs={'onchange': 'actionform.submit();'})
but invallid syntax when try load form. pretty sure attrs={'onchange': 'actionform.submit();'})
problem, not sure how else it.
you need set widget
argument on field , pass attrs
argument:
action = forms.choicefield(choices=choices, widget=forms.select(attrs={'onchange': 'actionform.submit();'}))
also, choices
list should contain items containing 2 things inside:
choices = [(0, 'create new folder'), (1, 'delete'), (2, 'read'), (3, 'unread')]
Comments
Post a Comment