Thursday, March 28, 2013

Re: showing an Integerfield as checkbox in form with defaulted as "check"

Hey Abhishek,

In your form, you need to specify a form field to use django.forms.widgets.CheckboxInput (https://docs.djangoproject.com/en/dev/ref/forms/widgets/#checkboxinput) for this.

Here is an example

    from django import forms  from django.form.widgets import CheckboxInput  from django.forms.fields import IntegerField    def my_check_test(some_integer):      """      A custom check test used by CheckboxInput.      """      return some_integer%2 == 0    class SimpleForm(forms.Form):      my_field = IntegerField(widget=CheckboxInput(check_test=my_check_test))

On Thu, Mar 28, 2013 at 5:57 PM, Abhishek Kumar <abhi.creations@gmail.com> wrote:
> I am trying to show an integer field as check box and wanted to show it as
> default check.
> Does anyone know how to do this.
>
> thanks
> ak
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  



--

Sincerely,
Pankaj Singh
http://about.me/psjinx

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

No comments:

Post a Comment