s_skaidocsTài liệu
LINGO REFERENCE

forms & form()

Dùng form đã published và được cấp cho runtime.

Hiển thị form

LINGO
{{ form('contact') }}

Helper tạo HTML form. Khi key không tồn tại hoặc chưa publish, helper trả chuỗi rỗng.

Tự dựng giao diện

LINGO
{% if forms.contact %}
{% set contact = forms.contact %}
<form action="{{ contact.action_url }}" method="{{ contact.method }}">
  {% for field in contact.fields %}
    <label>{{ field.label }}</label>
  {% endfor %}
</form>
{% endif %}

Ví dụ này minh họa đọc metadata, chưa phải form nhập hoàn chỉnh. Khi thêm input, thuộc tính name phải trùng field.key và loại input phải phù hợp field.

Kết quả submit

LINGO
{% if success and success.key == "contact" %}
  <p>{{ success.message }}</p>
{% endif %}
{% if error and error.key == "contact" %}
  <p>{{ error.message }}</p>
{% endif %}