Files
2026-08-27 18:09:39 -03:00

69 lines
1.9 KiB
HTML

---
name:
type: "string"
site:
type: "string"
turbo_stream:
type: "string"
default: ""
comment: "Enable Turbo Streams for this form. The value is the name of a /assets/turbo_streams/NAME/ that replaces the form after submission."
schema:
type: "hash"
default_value_types:
type: "hash"
default:
text: "string"
long_text: "string"
number: "string"
date: "string"
email: "string"
password: "string"
date_of_birth: "string"
checkbox: "hash"
radio: "hash"
switch: "hash"
select: "array"
checkbox_group: "array"
checkbox_group_with_other: "array"
radio_group: "array"
datalist: "array"
nested_form: "nested_form"
multi_nested_form: "nested_form"
default_label_class_by_type:
type: "hash"
default:
multi_nested_form: "h3"
nested_form: "h3"
---
{% comment %}
This invisible image has two functions to prevent spam:
* Starts the rate limit counter on the webserver, form can't be
submitted immediately, assuming a visitor takes some time to actually
fill out the form.
* If the website has contact forms enabled, it'll retrieve a cookie
needed for the form submission to be processed.
{% endcomment %}
<img loading="eager" class="d-none invisible" src="api/v1/sites/{{ site }}/contact/cookie.png">
{% unless turbo_stream == empty %}
<turbo-frame id="{{ name }}">
{% endunless %}
<form
method="post"
action="api/v1/sites/{{ site }}/contact/{{ name }}"
data-controller="form-dependencies form-validation"
data-action="form-validation#validate"
>
{% unless turbo_stream == empty %}
{% render 'forms/hidden.html', id: 'turbo_stream', value: turbo_stream %}
{% endunless %}
{% render 'forms/form_fields.html', schema:, default_value_types:, default_label_class_by_type: %}
<button type="submit" class="btn btn-primary btn-lg">Solicitar afiliación</button>
</form>
{% unless turbo_stream == empty %}
</turbo-frame>
{% endunless %}