{# WEB-2 §29 — the shared buyer-intent form. SHORT by law: name, work email, company,
country + only the intent's own extras. Posts to the one endpoint; WebIntentCore is
the validation contract. Caller sets: intent, cta (button label), extras (list of
{name, label, type?, options?}) — extras default to none (the demo form baseline). #}
{% set extras = extras|default([]) %}
<form class="pp-form" id="ppIntentForm" data-intent="{{ intent }}"
action="{{ url('honeybee_intent_request', {'intent': intent}) }}" method="post">
<div class="row">
<div><label>Name *</label><input name="name" required maxlength="120"></div>
<div><label>Work email *</label><input name="email" type="email" required maxlength="190"></div>
</div>
<div class="row">
<div><label>Company{% if intent == 'partner' %} *{% endif %}</label>
<input name="company" maxlength="190" {% if intent == 'partner' %}required{% endif %}></div>
<div><label>Country</label><input name="country" maxlength="90"></div>
</div>
{% for f in extras %}
<label>{{ f.label }}</label>
{% if f.options is defined %}
<select name="{{ f.name }}">
<option value=""></option>
{% for opt in f.options %}<option>{{ opt }}</option>{% endfor %}
</select>
{% else %}
<input name="{{ f.name }}" maxlength="300">
{% endif %}
{% endfor %}
<label>Anything we should know?</label>
<textarea name="note" rows="3" maxlength="2000"></textarea>
<button type="submit">{{ cta }}</button>
<div class="ok"></div>
<div class="err"></div>
</form>
<script>
(function () {
var f = document.getElementById('ppIntentForm');
if (!f) return;
f.addEventListener('submit', function (e) {
e.preventDefault();
var btn = f.querySelector('button'); btn.disabled = true;
fetch(f.action, { method: 'POST', body: new FormData(f) })
.then(function (r) { return r.json(); })
.then(function (j) {
var box = f.querySelector(j.success ? '.ok' : '.err');
box.textContent = j.message || (j.success ? 'Sent.' : 'Something went wrong.');
box.style.display = 'block';
if (j.success) {
f.querySelectorAll('input,select,textarea').forEach(function (i) { i.value = ''; });
// WEB-5 §33: form_complete with the §29 intent as meta
if (window.hbWa) { window.hbWa('form_complete', f.getAttribute('data-intent') || ''); }
}
else { btn.disabled = false; }
})
.catch(function () {
var box = f.querySelector('.err');
box.textContent = 'Could not send — please try again or email us.';
box.style.display = 'block'; btn.disabled = false;
});
});
})();
</script>