field1 = CharField(max_length=10, widget=HiddenInput)
That will create a hidden charfield with max length 10. You may have
to put "forms.Charfield(..." depending on how you imported newforms.
As for the FloatField, I can't think of any way to get a float value
out of the default clean() method, but you can override it with
clean_<fieldname>() in your form class definition. For example:
>From the newforms regressiontest:
As in
Field.clean(), the clean_XXX() method should return the cleaned value.
In the
clean_XXX() method, you have access to self.clean_data, which is a
dictionary
of all the data that has been cleaned *so far*, in order by the fields,
including the current field (e.g., the field XXX if you're in
clean_XXX()).
field2 = RegexField(<some regex to validate your float>)
def field2_clean(self):
return float(self.clean_data['field2'])
Obviously, you should build some error handling into that clean method
in case your regex validator doesn't catch a value that float() can't
handle. By calling self.clean_data[<fieldname>], you invoke the parent
clean() method for that field, so it will perform whatever validation
it is designed to do before doing your custom validation/cleaning in
your new clean method.
I personally am all for a FloatField, and would be happy to write that
code if other feel it would be useful and proper in newforms.
On Jan 24, 12:55 pm, "ak" <[EMAIL PROTECTED]> wrote:
> Sorry, could you provide me an example of how to make a field to be
> displayed as hidden ?
> I've looked through the code (i have the latest svn on my pc) but it
> doesn't seem to be clean for me.
>
> And please take a look
> here:http://code.djangoproject.com/browser/django/trunk/django/newforms/fi...
> IntegerField.clean() returns int() of an argument but
> RegexField.clean() returns unicode string, not float.
> I understand that anything can be done through hacks but django is for
> perfectionists, isn't it ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---