任何人都可以請告訴我如何將css類分配給選項值。 我想改變每個選擇與小圖像的背景,所以我怎麼能與wtforms和CSS呢?將CSS類添加到WTForms SelectField中的選項
class RegisterForm(Form):
username = TextField('username', [validators.Length(min=3, max=50), validators.Required()])
img_url = SelectField('avatar',
choices=[('static/images/avatars/1.jpg', '1'),
('static/images/avatars/2.jpg', '2'),
('static/images/avatars/3.jpg', '3'),
('static/images/avatars/4.jpg', '4'),
('static/images/avatars/5.jpg', '5'),
('static/images/avatars/6.jpg', '6'),
('static/images/avatars/7.jpg', '7'),
('static/images/avatars/8.jpg', '8'),
('static/images/avatars/9.jpg', '9'),
('static/images/avatars/10.jpg','10')])