Python Flask WTForms: How can I disable a field dynamically in a view?


Question

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?

1
8
5/23/2017 12:10:11 PM

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()],
)
9
1/22/2017 8:00:15 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon