From dbe4a6792b8675c6c767946ea5ff5f3db8b35a05 Mon Sep 17 00:00:00 2001 From: Rob Raymond Date: Wed, 28 Aug 2013 09:05:40 -0600 Subject: [PATCH] Implement required field indicator Change Horizon's use of forms to set 'required' css class for required fields. Change template _form_fields.html to include Django field classes in order to honor above setting. Also changed horizon workflow to set "required" class on tabs of steps that contain required fields. Horizon CSS appends an asterisk after the field label and tab text based on "required" classname. The current indicator is based on review with horizon UX people and can be customized easily. Change-Id: I03261328d70abcefd13f609088ccb4d58ef30067 Implements: blueprint required-fields --- horizon/forms/base.py | 2 ++ horizon/templates/horizon/common/_form_fields.html | 2 +- horizon/templates/horizon/common/_workflow.html | 2 +- horizon/workflows/base.py | 11 +++++++++++ .../dashboards/project/networks/workflows.py | 6 +----- .../static/dashboard/less/horizon.less | 9 +++++++++ 6 files changed, 25 insertions(+), 7 deletions(-) diff --git a/horizon/forms/base.py b/horizon/forms/base.py index 2653f00377..605568a2ce 100644 --- a/horizon/forms/base.py +++ b/horizon/forms/base.py @@ -36,6 +36,8 @@ class SelfHandlingForm(SelfHandlingMixin, forms.Form): A base :class:`Form ` class which includes processing logic in its subclasses. """ + required_css_class = 'required' + def api_error(self, message): """ Adds an error to the form's error dictionary after validation diff --git a/horizon/templates/horizon/common/_form_fields.html b/horizon/templates/horizon/common/_form_fields.html index 21a9abdfdd..35676142a7 100644 --- a/horizon/templates/horizon/common/_form_fields.html +++ b/horizon/templates/horizon/common/_form_fields.html @@ -7,7 +7,7 @@ {% endif %} {% for field in form.visible_fields %} -
+
{{ field.label_tag }} {% if field.errors %} {% for error in field.errors %} diff --git a/horizon/templates/horizon/common/_workflow.html b/horizon/templates/horizon/common/_workflow.html index 4730af1bac..d2ef8b32e7 100644 --- a/horizon/templates/horizon/common/_workflow.html +++ b/horizon/templates/horizon/common/_workflow.html @@ -13,7 +13,7 @@ {% block modal-body %}