Skip to main content
Documentation/Developers/APIs/Hooks Reference/Forms

Forms

These PHP hooks differ from front-end events and custom submission actions.

Field Validation

Use the Form Field Validation Filter to add custom PHP validation before submission actions run. The reference includes the callback arguments and a complete example.

Markup and Email

Filter Arguments Return
breakdance_render_form_html $output, $props, $fields Markup/template string, processed further by the renderer.
breakdance_email_message $message Message string.
breakdance_email_headers $headers Array of header strings.
breakdance_email_attachments $attachments Array of file paths.

Email filters receive no form IDs. Preserve existing headers/attachments and reject unsafe header values/file paths.

Submission Hooks

breakdance_form_honeypot_triggered($settings, $fields, $ip) observes spam rejection, which returns apparent success. breakdance_form_submission_capability sets submission administration access.

Insert Markup Around Fields

The canonical Form Builder hooks let an extension insert HTML at these positions:

Action Callback arguments Position
breakdance_form_start $settings Beginning of the form.
breakdance_form_before_field $field, $settings Before each field.
breakdance_form_after_field $field, $settings After each field.
breakdance_form_before_footer $settings Before the form footer.
breakdance_form_end $settings End of the form.

Echo the markup from an action callback:

PHP
add_action('breakdance_form_start', function ($settings) {
    echo '<h4>' . esc_html($settings['form']['form_name'] ?? '') . '</h4>';
});

add_action('breakdance_form_before_field', function ($field, $settings) {
    echo !empty($field['advanced']['required'])
        ? '<p>This field is required.</p>'
        : '<p>This field is optional.</p>';
}, 10, 2);

add_action('breakdance_form_after_field', function ($field, $settings) {
    echo '<span>Type: ' . esc_html($field['type'] ?? '')
        . ' / ID: ' . esc_html($field['advanced']['id'] ?? '') . '</span>';
}, 10, 2);

add_action('breakdance_form_before_footer', function ($settings) {
    echo '<div class="breakdance-form-group">'
        . '<button type="button" class="my-autofill">Autofill</button></div>';
});

add_action('breakdance_form_end', function ($settings) {
    echo '<div class="breakdance-form-group">'
        . 'By submitting this form you agree to the terms of service.</div>';
});

The Autofill button is a markup example; connect it to your own JavaScript to implement the action. These PHP actions insert content while the form renders. To process submitted data, use the Form Actions API.