2015年6月19日 星期五

Flask WTForms example

References :
Reusing Flask-WTF forms. » BTHLabs
The Flask Mega-Tutorial, Part III: Web Forms - miguelgrinberg.com

WTForms dynamic set default SelectField value

myform = TestForm()
myform.select.default = 2
myform.process() // <-- :="" br="" missed="" this="" you="">
myform.title.data = 'xxxx'
....




References :
Change default value of a SelectField after form creation · Issue #106 · wtforms/wtforms

WTForms print validate error

print form.errors

WTForms Dynamic Select Field 'Not a Valid Choice' error

area = SelectField(coerce=int)




References :
python - Not a Valid Choice for Dynamic Select Field WTFORMS - Stack Overflow

WTForms get label text

{{ form.my_field.label.text }}




References :
accessing label property without html generation.. - Google Groups

2015年5月28日 星期四

CI Bonfire read global config variable

Example:

Config file :
application/config/address.php

Controller :
$this->load->config('address');
$address = config_item('address.countries');