Cannot set Field to type='hidden' in FormHelper
See original GitHub issueI have a formset and a formhelp object.
class MyHelper(FormHelper):
def __init__(self, *args, **kwargs):
super(MyHelper, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.layout = Layout(
Field('set_id', type='hidden', value='0')
)
When I render this formset, I get this error:
can't set attribute
The line that causes this error is:
/Users/cheng/.virtualenvs/waimai/lib/python2.7/site-packages/crispy_forms/utils.py in render_field
92. field_instance.widget.is_hidden = True
When I remove the type=‘hidden’ part from the Field definition, everything works. I don’t know why I cannot set this field to hidden. Here is the model definition of this field:
class Answer(models.Model):
set_id = models.IntegerField()
Thanks for your help!
Issue Analytics
- State:
- Created 8 years ago
- Comments:8
Top Results From Across the Web
Django crispy forms - Set hidden field value - Stack Overflow
The code is working, but I want to set the value of the hidden TEMPLATE field to "VALUE" when the form is submitted....
Read more >FormHelper - 2.x - CakePHP Cookbook
Since this is an edit form, a hidden input field is generated to override the default HTTP method. When creating forms for models...
Read more >ActionView::Helpers::FormHelper - Rails API
This way, the client either sends only the hidden field (representing the check box is unchecked), or both fields. Since the HTML specification...
Read more >Layouts — django-crispy-forms 1.14.0 documentation
This allows you to set the order of the fields, wrap them in divs or other ... If you want to render a...
Read more >form_for (ActionView::Helpers::FormHelper) - APIdock
:enforce_utf8 - If set to false, a hidden input with name utf8 is not output. :html - Optional HTML attributes for the form...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any ETA for PyPI release?
Is this ever going to be released? It’s sitting in the dev branch for two years now.