templates_modules_formsdir = $(templates_modulesdir)/forms
dist_templates_modules_forms_DATA = \
- src/templates/modules/forms/element.html \
+ src/templates/modules/forms/elements.html \
src/templates/modules/forms/fieldset.html \
- src/templates/modules/forms/group.html \
src/templates/modules/forms/index.html
templates_modules_forms_inputsdir = $(templates_modules_formsdir)/inputs
+++ /dev/null
-<div class="form-group">
- {% if e.label %}
- <label class="col-sm-2 control-label">{{ e.label }}</label>
- {% end %}
-
- <div class="col-sm-10 {% if not e.label %}col-sm-offset-2{% end %}">
- {% module FormInput(e) %}
-
- {% if e.help %}
- <span class="help-block">{{ e.help }}</span>
- {% end %}
- </div>
-</div>
--- /dev/null
+{% import westferry.backend.forms %}
+
+{% for element in elements %}
+ {% if isinstance(element, westferry.backend.forms.Fieldset) %}
+ {% module FormFieldset(element) %}
+ {% elif isinstance(element, westferry.backend.forms.MultilineTextInput) %}
+ {% module MultilineTextInput(element) %}
+ {% elif isinstance(element, westferry.backend.forms.PasswordInput) %}
+ {% module PasswordInput(element) %}
+ {% elif isinstance(element, westferry.backend.forms.TextInput) %}
+ {% module TextInput(element) %}
+ {% elif isinstance(element, westferry.backend.forms.YesNoInput) %}
+ {% module YesNoInput(element) %}
+ {% end %}
+{% end %}
{% import westferry.backend.forms %}
-<fieldset {% if fs.disabled %}disabled{% end %}>
+<fieldset class="fieldset" {% if fs.disabled %}disabled{% end %}>
{% if fs.label %}
<legend>{{ fs.label }}</legend>
- {% else %}
- <hr>
{% end %}
{% if fs.help %}
- <div class="row">
- <div class="col-md-10 col-md-offset-2">
- <span class="help-block">{{ fs.help }}</span>
- </div>
- </div>
+ <p>
+ {{ fs.help }}
+ </p>
{% end %}
- {% for e in fs %}
- {% if isinstance(e, westferry.backend.forms.Group) %}
- {% module FormGroup(e) %}
- {% else %}
- {% module FormElement(e) %}
- {% end %}
- {% end %}
+ {% module FormElements(fs) %}
</fieldset>
+++ /dev/null
-<div class="form-inline">
- {% for e in group %}
- <div class="form-group">
- {% if e.label %}
- <label>{{ e.label }}</label>
- {% end %}
-
- {% module FormInput(e) %}
- </div>
- {% end %}
-</div>
{% import westferry.backend.forms %}
-<form class="form-horizontal" method="{{ f.method }}" action="{{ f.action }}">
+<form method="{{ f.method }}" action="{{ f.action }}">
{% raw xsrf_form_html() %}
- {% for e in f %}
- {% if isinstance(e, westferry.backend.forms.Fieldset) %}
- {% module FormFieldset(e) %}
- {% elif isinstance(e, westferry.backend.forms.Group) %}
- {% module FormGroup(e) %}
- {% else %}
- {% module FormElement(e) %}
- {% end %}
- {% end %}
+ {% module FormElements(f) %}
- <div class="form-group">
- <div class="col-sm-10 col-sm-offset-2">
- <button type="submit" class="btn btn-primary">{{ f.submit_text or _("Submit") }}</button>
- </div>
- </div>
+ <button type="submit" class="primary button">{{ f.submit_text or _("Submit") }}</button>
</form>
-{% import westferry.backend.forms %}
+<label>
+ {% if input.label %}{{ input.label }}{% end %}
-{% if isinstance(input, westferry.backend.forms.MultilineTextInput) %}
- {% module MultilineTextInput(input) %}
-{% elif isinstance(input, westferry.backend.forms.PasswordInput) %}
- {% module PasswordInput(input) %}
-{% elif isinstance(input, westferry.backend.forms.TextInput) %}
- {% module TextInput(input) %}
-{% elif isinstance(input, westferry.backend.forms.YesNoInput) %}
- {% module YesNoInput(input) %}
+ {% block element %}{% end block %}
+</label>
+
+{% if input.help %}
+ <p class="help-text" id="XXX TODO">{{ input.help }}</p>
{% end %}
-<div class="checkbox">
- <label>
- <input type="checkbox" name="{{ input.name }}" {% if input.value %}checked{% end %}>
- {% if input.description %}{{ input.description }}{% end %}
- </label>
-</div>
+<input id="checkbox1" type="checkbox"
+ name="{{ input.name }}" {% if input.value %}checked{% end %}>
+
+{% if input.description %}
+ <label for="checkbox1">{{ input.description }}</label>
+{% end %}
-{% if input.prefix or input.suffix %}
- <div class="input-group">
- {% if input.prefix %}
- <div class="input-group-addon">{{ input.prefix }}</div>
- {% end%}
-{% end %}
+{% extends "base.html" %}
-<input type="{{ input.type }}" name="{{ input.name }}" class="form-control"
- {% if input.placeholder %}placeholder="{{ input.placeholder }}"{% end %}
- {% if input.disabled %}disabled{% end %}
- {% if input.readonly %}readonly{% end %} />
+{% block element %}
+ {% if input.prefix or input.suffix %}
+ <div class="input-group">
+ {% if input.prefix %}
+ <span class="input-group-label">{{ input.prefix }}</span>
+ {% end %}
+ {% end %}
-{% if input.prefix or input.suffix %}
- {% if input.suffix %}
- <div class="input-group-addon">{{ input.suffix }}</div>
- {% end %}
- </div>
-{% end %}
+ <input type="{{ input.type }}" name="{{ input.name }}"
+ {% if input.prefix or input.suffix %}class="input-group-field"{% end %}
+ {% if input.placeholder %}placeholder="{{ input.placeholder }}"{% end %}
+ {% if input.disabled %}disabled{% end %}
+ {% if input.readonly %}readonly{% end %} />
+
+ {% if input.prefix or input.suffix %}
+ {% if input.suffix %}
+ <span class="input-group-label">{{ input.suffix }}</span>
+ {% end %}
+ </div>
+ {% end %}
+{% end block %}
-<textarea class="form-control" name="{{ input.name }}" rows="{{ input.lines }}"
- {% if input.placeholder %}placeholder="{{ input.placeholder }}"{% end %}
- >{% if input.value %}{{ input.value }}{% end %}</textarea>
+{% extends "base.html" %}
+
+{% block element %}
+ <textarea class="form-control" name="{{ input.name }}" rows="{{ input.lines }}"
+ {% if input.placeholder %}placeholder="{{ input.placeholder }}"{% end %}
+ >{% if input.value %}{{ input.value }}{% end %}</textarea>
+{% end block %}
f=form, forms=forms)
-class FormElementModule(base.BaseUIModule):
- def render(self, element):
- assert isinstance(element, forms.Element)
-
- return self.render_string("modules/forms/element.html", e=element)
+class FormElementsModule(base.BaseUIModule):
+ def render(self, elements):
+ return self.render_string("modules/forms/elements.html", elements=elements)
class FormFieldsetModule(base.BaseUIModule):
return self.render_string("modules/forms/fieldset.html", fs=fieldset)
-class FormGroupModule(base.BaseUIModule):
- def render(self, group):
- return self.render_string("modules/forms/group.html", group=group)
-
-
-class FormInputModule(base.BaseUIModule):
- """
- This is a proxy module that will pick the right
- *InputModule.
- """
- def render(self, input):
- return self.render_string("modules/forms/inputs/base.html", input=input)
-
-
class TextInputModule(base.BaseUIModule):
def render(self, input):
assert isinstance(input, forms.TextInput)