django-simple-captcha icon indicating copy to clipboard operation
django-simple-captcha copied to clipboard

widget attrs doesn't work

Open shuai336 opened this issue 7 years ago • 3 comments

captcha = CaptchaField(error_messages={ widget=CaptchaTextInput(attrs={'placeholder': message})) the placeholder doesn't work

shuai336 avatar Jun 13 '18 03:06 shuai336

@ziima this might be in the realm of your recent changes, what is your take on this?

mbi avatar Jun 13 '18 06:06 mbi

I just want add a placeholder at the captcha field

captcha = CaptchaField(error_messages={'invalid': e_message}, widget=CaptchaTextInput(attrs={'placeholder': p_message}, output_format=u'%(hidden_field)s %(text_field)s %(image)s'))

the output_format is ok, but the placeholder doesn't work

shuai336 avatar Jun 13 '18 07:06 shuai336

Using django-simple-captcha 0.5.7, django 1.11 and python 2.7 following works for me:

from django import forms
from captcha.fields import CaptchaField, CaptchaTextInput

class MyForm(forms.Form):
    captcha = CaptchaField(widget=CaptchaTextInput(attrs={'placeholder': 'SMEGHEAD!'}))

form = MyForm()
unicode(form)

@shuai336 ~~I'm not entirely sure how your form looks like, but~~ output_format is now deprecated in favor of template based rendering. One of the reasons was to fix the behavior of widget attributes. Edit: I got it, once I submitted the comment.

ziima avatar Jun 20 '18 11:06 ziima