From 0b180a7e9ab0d6f9ceb95abefee8c25fdd9f49f7 Mon Sep 17 00:00:00 2001 From: Alexis Metaireau Date: Wed, 10 Aug 2011 00:20:16 +0200 Subject: [PATCH] use checkboxes rather than select multiple. Fixes #10 --- budget/forms.py | 20 +++++++++++++++++++- budget/static/main.css | 8 ++++++++ budget/static/uniform/blue.uni-form.css | 4 ++++ budget/templates/forms.html | 2 +- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/budget/forms.py b/budget/forms.py index afa86cc..d797d69 100644 --- a/budget/forms.py +++ b/budget/forms.py @@ -1,7 +1,24 @@ from flaskext.wtf import * +from wtforms.widgets import html_params from models import Project, Person, Bill from datetime import datetime + +def select_multi_checkbox(field, ul_class='', **kwargs): + kwargs.setdefault('type', 'checkbox') + field_id = kwargs.pop('id', field.id) + html = [u'') + return u''.join(html) + + class ProjectForm(Form): name = TextField("Project name", validators=[Required()]) id = TextField("Project identifier", validators=[Required()]) @@ -32,7 +49,7 @@ class BillForm(Form): payer = SelectField("Payer", validators=[Required()]) amount = DecimalField("Amount payed", validators=[Required()]) payed_for = SelectMultipleField("Who has to pay for this?", - validators=[Required()]) + validators=[Required()], widget=select_multi_checkbox) submit = SubmitField("Add the bill") def save(self): @@ -68,3 +85,4 @@ class InviteForm(Form): for email in [email.strip() for email in form.emails.data.split(",")]: if not validator.regex.match(email): raise ValidationError("The email %s is not valid" % email) + diff --git a/budget/static/main.css b/budget/static/main.css index bd59b2a..f42a1fe 100644 --- a/budget/static/main.css +++ b/budget/static/main.css @@ -11,6 +11,14 @@ a { color: #a45900; } +.fright{ + float: right; +} + +.fleft{ + float: left; +} + #title{ margin-top: 10px; } diff --git a/budget/static/uniform/blue.uni-form.css b/budget/static/uniform/blue.uni-form.css index c1f70ec..2c67c82 100644 --- a/budget/static/uniform/blue.uni-form.css +++ b/budget/static/uniform/blue.uni-form.css @@ -151,3 +151,7 @@ /* Use .first and .last classes to control the layout/spacing of your columns */ .uniForm .col.first{ width: 49%; float: left; clear: none; } .uniForm .col.last { width: 49%; float: right; clear: none; margin-right: 0; } + +.ctrlHolder ul{ + float: right; +} diff --git a/budget/templates/forms.html b/budget/templates/forms.html index d462a82..62ad4b8 100644 --- a/budget/templates/forms.html +++ b/budget/templates/forms.html @@ -44,7 +44,7 @@ {{ input(form.what) }} {{ input(form.payer) }} {{ input(form.amount) }} - {{ input(form.payed_for, multiple=True) }} + {{ input(form.payed_for) }} {{ input(form.submit) }} {% endmacro %}