I've been able to implement this change to create Field which is disabled in WTForms. How would I selectively disable a field in my view before rendering it?
vim forms.py:
add_time = DateTimeField(
'添加时间',
format='%Y-%m-%d %H:%M:%S',
default=datetime.datetime.now(),
# I use bs3,and it well add input an attribute disabled
render_kw={'disabled':''},
validators=[DataRequired()],
)
It's almost as @Bibhas proposed. If I understand this correctly and you want to disable a field through the html disabled attribute, then the following worked for me:
form.field(disabled=True)
This answer might be a bit late, but if any one else has this problem it might help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With