http://docs.ckan.org/en/2.9/contributing/frontend/templating.html#form-macros
CKAN 用 form macro 產生基本的表單輸入欄位,複雜的自己寫。
這些 macros 可用 {% import %} 匯入網頁。如下:
{% import 'macros/form.html' as form %}
form.input()
包含產生對應的 label, error message。
name - The name of the form parameter.
id - The id to use on the input and label. Convention is to prefix with 'field-'.
label - The human readable label.
value - The value of the input.
placeholder - Some placeholder text.
type - The type of input eg. email, url, date (default: text).
error - A list of error strings for the field or just true to highlight the field.
classes - An array of classes to apply to the control-group.
attrs - Dictionary of extra tag attributes
is_required - Boolean of whether this input is required for the form to validate
如:
{% import 'macros/form.html' as form %}
{{ form.input('title', label=_('Title'), value=data.title, error=errors.title) }}
其餘參考: http://docs.ckan.org/en/2.9/contributing/frontend/templating.html#form-macros
沒有留言:
張貼留言