{%- import "macros/form.html" as _form -%} {%- macro extra_field(content, index=0, data={}, errors={}, name_template='extras__{index}__') -%} {%- do kwargs -%} {%- set prefix = name_template.format(index=index) -%} {%- set params = { "names": (prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), "id": 'field-extras-%d' % (index+1), "label": _('Custom Field'), "values": (data.key, data.value, data.deleted), "error": errors[prefix ~ 'key'] or errors[prefix ~ 'value'] } -%} {{ _form.custom(**params) }} {%- endmacro %} {%- macro extra_fields_collection(extras=[], errors={}, limit=3) -%} {{ h.snippet('snippets/custom_form_fields.html', extras=extras, errors=errors, limit=limit, **kwargs) }} {%- endmacro %} {%- macro field_errors(errors) -%} {%- if errors -%} {{ errors | join(', ') }} {%- endif %} {%- endmacro %} {%- macro file_input(content, accept, capture, multiple) -%} {%- if multiple -%} {%- do kwargs.setdefault("attrs", {}).setdefault("multiple", true) -%} {%- endif %} {%- if accept -%} {%- do kwargs.setdefault("attrs", {}).setdefault("accept", accept) -%} {%- endif %} {%- if capture -%} {%- do kwargs.setdefault("attrs", {}).setdefault("capture", capture) -%} {%- endif %} {{ ui.input(content, type="file", **kwargs) }} {%- endmacro %} {%- macro form(content, method, action, enctype, include_csrf=true) -%} {{ ui.form_start(method, action, enctype, **kwargs) }} {{ h.csrf_input() if include_csrf and method and method|upper != "GET" }} {{ content }} {{ ui.form_end() }} {%- endmacro %} {%- macro form_actions(content) -%}
{{ content }}
{%- endmacro %} {%- macro form_end(content) -%} {%- do kwargs -%} {{ content }} {%- endmacro %} {%- macro form_errors(errors) -%} {%- do kwargs -%} {{ _form.errors(errors) if errors }} {%- endmacro %} {%- macro form_start(content, method, action, enctype) -%}
{{ content }} {%- endmacro %} {%- macro hidden_input(name, value) -%} {%- do kwargs -%} {{ _form.hidden(name, value) }} {%- endmacro %} {%- macro input(content, name, id, label, value, required, placeholder, type, icon, errors=[]) -%} {%- set params = { "name": name, "id": id, "label": label, "value": value, "placeholder": placeholder, "type": type, "error": errors, "is_required": required, "attrs": kwargs.attrs or {'class': 'form-control'}, } -%} {%- set func = _form.input -%} {%- if kwargs.prefix -%} {%- set func = _form.prepend -%} {%- do params.update({"prepend": kwargs.prefix}) -%} {%- endif %} {%- call func(**params) -%}{{ content }}{%- endcall %} {%- endmacro %} {%- macro form_annotation() -%} {%- do kwargs -%} {{ _form.required_message() }} {%- endmacro %} {%- macro field_info(content, inline=false, classes=[]) -%} {%- do kwargs -%} {{ _form.info(content, inline, classes) }} {%- endmacro %} {%- macro checkbox(content, name, id, checked, label, required, placeholder, value="", errors=[]) -%} {%- set params = { "name": name, "id": id, "label": label, "value": value, "checked": checked, "placeholder": placeholder, "error": errors, "is_required": required, "attrs": kwargs.attrs or {}, } -%} {%- call _form.checkbox(**params) -%}{{ content }}{%- endcall %} {%- endmacro %} {%- macro markdown_popover(id, title=_("Markdown quick reference")) -%} {%- call ui.util.call(ui.popover, title=title, id=id, **kwargs) -%} {%- if content -%} {{ content }} {%- else -%} {%- trans -%}

__Bold text__ or _italic text_

# title
## secondary title
### etc

* list
* of
* items

http://auto.link.ed/

Full markdown syntax

Please note: HTML tags are stripped out for security reasons

{%- endtrans %} {%- endif %} {%- endcall -%} {%- endmacro %} {%- macro markdown(content, name, id, label, value, placeholder, required, errors=[], group_class="form-group control-full") -%} {%- set params = { "name": name, "id": id, "label": label, "value": value, "placeholder": placeholder, "error": errors, "is_required": required, "attrs": kwargs.attrs or {'class': 'form-control'}, } -%} {%- call _form.markdown(**params) -%}{{ content }}{%- endcall %} {%- endmacro %} {%- macro radio(content, checked, value="on") -%} {{ ui.input(content, checked=checked, value=value or "on", type="radio", **kwargs) }} {%- endmacro %} {%- macro range_input(content, min_value, max_value, step) -%} {%- if min_value is defined -%} {%- do kwargs.setdefault("attrs", {}).setdefault("min", min_value) -%} {%- endif %} {%- if max_value is defined -%} {%- do kwargs.setdefault("attrs", {}).setdefault("max", max_value) -%} {%- endif %} {%- if step is defined -%} {%- do kwargs.setdefault("attrs", {}).setdefault("step", step) -%} {%- endif %} {{ ui.input(content, type="range", **kwargs) }} {%- endmacro %} {%- macro select(content, name, id, label, options, selected) -%} {%- set params = { "name": name, "id": id, "label": label, "options": options, "selected": selected, "error": errors, "is_required": required, "attrs": kwargs.attrs or {'class': 'form-control'}, } -%} {%- call _form.select(**params) -%}{{ content }}{%- endcall %} {%- endmacro %} {%- macro select_box(content, nested_content, name, id, label, multiple, required, autocomplete, errors=[], group_class="form-group") -%} {%- set field_id = id or (name and "field-" ~ name) or (label and ui.util.id()) or "" -%}
{%- if label -%} {%- endif %} {{ nested_content }} {{ ui.field_errors(errors) if errors }}
{%- endmacro %} {%- macro select_option(content, value, selected) -%} {%- endmacro %} {%- macro submit(content, value, name) -%} {%- set attrs = kwargs.setdefault("attrs", {}) -%} {%- if value -%}{%- do attrs.update({"value": value}) -%}{%- endif %} {%- if name -%}{%- do attrs.update({"name": name}) -%}{%- endif %} {{- ui.button(content, type="submit", **kwargs) }} {%- endmacro %} {%- macro textarea(content, name, id, label, value, placeholder, required, errors=[], group_class="form-group control-full") -%} {%- set params = { "name": name, "id": id, "label": label, "value": value, "placeholder": placeholder, "error": errors, "is_required": required, "attrs": kwargs.attrs or {'class': 'form-control'}, } -%} {%- call _form.textarea(**params) -%}{{ content }}{%- endcall %} {%- endmacro %} {%- macro fieldset(content, legend) -%}
{%- if legend -%} {{ legend }} {%- endif %} {{ content }}
{%- endmacro %}