Hooks for the HTML attributes a form control can have and for how long the form keeps stored submissions. For what happens when a form is submitted, see Forms: processing and validation.
Jump to
- Form controls
- Stored submissions
Form controls
generateblocks_form_control_html_attributes
GB Pro — since GenerateBlocks 2.6.
The generateblocks_form_control_html_attributes filter changes which custom HTML attributes a Form Field Control block may output. An entry ending in -* allows every attribute with that prefix.
Parameters: $allowed_attributes (array of attribute names and prefix markers). Default: aria-*, data-*, autocapitalize, autocomplete, enterkeyhint, inputmode, max, maxlength, min, minlength, pattern, spellcheck, step and title.
The renderer always blocks the attributes it generates or controls at runtime: name, id, type, value, class, style, required, checked, selected, disabled, readonly, multiple, placeholder, rows, aria-required and aria-invalid. Event handlers, form* attributes and data-gb-* attributes are blocked too, even if you add them here.
add_filter( 'generateblocks_form_control_html_attributes', function( $allowed_attributes ) {
$allowed_attributes[] = 'list';
return $allowed_attributes;
} );
Related: generateblocks_form_type_sanitizers Guide: Forms
Stored submissions
generateblocks_form_submissions_retention_days
GB Pro — since GenerateBlocks 2.6.
The generateblocks_form_submissions_retention_days filter sets how many days a form’s stored submissions are kept.
Parameters: $retention_days (int, the retention period in days), $form_id (int, the form post ID). Default: 180. The result is raised to at least 1.
Example 1: set a form to retain submissions for 90 days.
add_filter( 'generateblocks_form_submissions_retention_days', function( $retention_days, $form_id ) {
if ( 123 === $form_id ) { // Replace 123 with your actual form ID
return 90;
}
return $retention_days;
}, 10, 2 );
Related: generateblocks_form_submissions_max_records_per_form Guide: Forms
generateblocks_form_submissions_max_records_per_form
GB Pro — since GenerateBlocks 2.6.
The generateblocks_form_submissions_max_records_per_form filter sets how many stored submissions a form keeps.
Parameters: $max_records (int, the number of submissions to store), $form_id (int, the form post ID). Default: 500. The result is raised to at least 1.
Example 1: set a form to store 1000 submissions.
add_filter( 'generateblocks_form_submissions_max_records_per_form', function( $max_records, $form_id ) {
if ( 123 === $form_id ) { // Replace 123 with your actual form ID
return 1000;
}
return $max_records;
}, 10, 2 );
Related: generateblocks_form_submissions_retention_days Guide: Forms