mardi 30 juin 2015

Django crispy forms: add text next to a checkbox?

It seems to be simple but I can't figure out how to add some text next to my checkbox. I don't want to override the template (I think I don't need to). For now, I have a checkbox that works, but how to put some text like "I Agree TOS" at the right of the checkbox?

Here is what I have: http://ift.tt/1JnAniM

class TenantSignupForm(forms.Form):
    email = forms.EmailField()
    password = forms.CharField(
        widget=forms.PasswordInput(),
        validators=[RegexValidator(regex=r'[A-Za-z0-9@#$%^&+=]{8,}', code=None),
                    MaxLengthValidator(32)])
    password_confirmation = forms.CharField(
        widget=forms.PasswordInput())
    agree_tos = forms.BooleanField()

    def __init__(self, *args, **kwargs):
        super(TenantSignupForm, self).__init__(*args, **kwargs)
        self.helper = unvariable_helper(self)
        self.helper.form_class = 'm-t'
        self.helper.form_action = 'signup'
        self.helper.layout = Layout(
            Field('email', placeholder="Email"),
            Field('password', placeholder="Password"),
            Field('password_confirmation', placeholder="Confirm your password"),
            Field('agree_tos', wrapper_class='i-checks'),
            FormActions(
                Submit('signup',
                       'Register',
                       css_class='btn btn-primary block full-width m-b'
                      )
                )
        )




Aucun commentaire:

Enregistrer un commentaire