Markup for the AI (syntax)
A form is a normal <form> with data-bos-form. The fields are <input>, <select> and <textarea> with a name attribute.
<form class="contact-form" data-bos-form="contacto" data-bos-name="Formulario de contacto"
data-bos-success="¡Gracias! Te responderemos en menos de 24 horas."
data-bos-subject="Nuevo contacto de {nombre}">
<p class="field">
<label for="contacto-nombre" data-bos-edit="text" data-bos-id="form-name-label" data-bos-name="Etiqueta: nombre">Nombre</label>
<input id="contacto-nombre" type="text" name="nombre" autocomplete="name" placeholder="Tu nombre" required maxlength="120">
</p>
<p class="field">
<label for="contacto-email" data-bos-edit="text" data-bos-id="form-email-label" data-bos-name="Etiqueta: email">Email</label>
<input id="contacto-email" type="email" name="email" autocomplete="email" required>
</p>
<p class="field">
<label for="contacto-servicio" data-bos-edit="text" data-bos-id="form-service-label" data-bos-name="Etiqueta: servicio">¿Qué necesitas?</label>
<select id="contacto-servicio" name="servicio">
<option value="">Elige una opción</option>
<option value="web">Diseño web</option>
<option value="seo">SEO</option>
</select>
</p>
<p class="field">
<label for="contacto-mensaje" data-bos-edit="text" data-bos-id="form-message-label" data-bos-name="Etiqueta: mensaje">Mensaje</label>
<textarea id="contacto-mensaje" name="mensaje" rows="5" required maxlength="5000"></textarea>
</p>
<p class="consent">
<label><input type="checkbox" name="privacidad" value="1" required data-bos-consent>
<span data-bos-edit="text" data-bos-id="form-consent" data-bos-name="Texto de consentimiento">Acepto que uséis mis datos para responder a mi mensaje.</span></label>
</p>
<button type="submit" class="btn"><span data-bos-edit="text" data-bos-id="form-submit" data-bos-name="Botón enviar">Enviar mensaje</span></button>
<div data-bos-form-message></div>
</form><form> attributes
| Attribute | Use |
|---|---|
data-bos-form | Required. Stable form id (contacto, presupuesto…). Unique within the section. Don’t change it once in production: settings and messages are saved with it. |
data-bos-name | Name the administrator sees (list, emails, messages). |
data-bos-success | Success message in the HTML’s language. It can be changed per language in the panel. |
data-bos-redirect | Optional. Page to go to after submitting: a URL or gracias.html (a package page; its version in the visitor’s language is used). |
data-bos-subject | Optional. Subject of the email notification. Supports {campo}, {form}, {site}, {page} and {lang}. |
data-bos-reply-to | Optional. name of the email field to reply to. Defaults to the first type="email". |
data-bos-error-message | Optional. General message when there are errors. Defaults to “Check the highlighted fields.” |
Field attributes
| Attribute | Use |
|---|---|
name | Required. Letters, numbers, - and _, starting with a letter (nombre, e-mail, servicios[]). Don’t use dots or spaces. Names that start with _bos are reserved. |
required | Required field (also validated on the server). |
type | text, email, tel, url, number, date, textarea, select, checkbox, radio, file, hidden… email, tel, url, number and date are validated on the server. |
maxlength, minlength, min, max, pattern | Respected on the server. Without maxlength, the limit is 1000 characters (10,000 in textarea). |
data-bos-consent | Consent checkbox (GDPR). The accepted text and the date are saved. |
data-bos-label | Optional. Label for the email and the panel if the field has no <label>. |
accept | On type="file", limits the extensions (.pdf,.png or image/*). |
data-bos-error | The field’s own error message. It replaces the validation ones (also in package forms). |
data-bos-required | Required checkbox group: checking one is enough. With required, the browser would force you to check them all. |
- Labels: taken from
<label for="id">, from the<label>that wraps the field, fromaria-labelor from theplaceholder, in this order. Inradioand checkbox groups (name="servicios[]"), from the<fieldset>‘s<legend>. - Message: the result is shown in the element with
data-bos-form-message. If there isn’t one, one is added at the end of the form. - Multiple values: checkboxes with
name="x[]"and<select multiple>save all the chosen options.
Editable and translatable texts
- Labels, the consent text and the button are normal BuilderOS fields: mark them with
data-bos-edit="text"(orrichtextif they contain a link), withdata-bos-idanddata-bos-name. They’re edited in the visual editor and translated ini18n/<idioma>.jsonlike any other field. - In the button, put the text in a
<span data-bos-edit="text">inside the<button>(editing text directly on a<button>causes problems in some browsers). - What isn’t an element’s content (placeholders,
<option>texts, success message and redirect) is translated in the reserved key_formsofi18n/<idioma>.json, by form id:
{
"contact": {
"form-name-label": "Name",
"form-submit": "Send message"
},
"_forms": {
"contacto": {
"success": "Thank you! We will get back to you within 24 hours.",
"redirect": "thanks.html",
"placeholders": { "nombre": "Your name", "mensaje": "Tell us about your project" },
"options": { "servicio": { "": "Choose an option", "web": "Web design", "seo": "SEO" } }
}
}
}- The validation messages (“This field is required”…) come out in the page’s language: Spanish, English, Portuguese, French, German and Italian are included; the rest use English. You can change them with the
builder_os_forms_messagesfilter.
❌ What NOT to do
- Don’t set
action,methodor your own submission JavaScript: BuilderOS replaces them. - Don’t put the form inside a
text,richtextorshortcodefield (they replace all their content). - Don’t use
data-bos-editon<input>,<select>or<textarea>: the editable fields are the labels and the button. - Don’t use
data-bos-formon anything that isn’t a<form>.