Tuesday, August 2, 2011

Re: how to create a hidden field

On Tue, Aug 2, 2011 at 2:37 PM, webcomm <ryandw@gmail.com> wrote:
>> That would hide the field called 'itemid' from the model 'News'. Are
>> you saying it doesn't?
>
> That's right.  It's not working.  The field isn't hidden.
>

Have you simplified your example? This functionality works well when
used correctly:

>>> class TestForm(ModelForm):
... range = CharField(widget=HiddenInput)
... class Meta:
... model=Foo
...
>>> f=TestForm()
>>> f.as_p()
u'<p><label for="id_name">Name:</label> <input type="text" name="name"
id="id_name" /><input type="hidden" name="range" id="id_range" /></p>'

As you can see, the range field is clearly hidden.

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment