Skip to content

ITC Forms 0.15.6Changelog

Custom field types

A custom type requires paired server and browser registration. JavaScript alone cannot make a type valid or safe. Custom renderers can replace the control while retaining a supported core value shape. See extension recipes for working PHP/React renderers and field-level settings. Payments and calculations use isolated add-on contracts; their implementations are examples of keeping sensitive or commercial logic outside Core while using the same versioned extension envelope.

add_filter( 'itc_forms_field_type_registry', function ( array $types ): array {
$types['company_code'] = [
'public' => true,
'control' => 'input',
'inputType' => 'text',
'sanitize' => 'text',
'validation' => 'text',
'maxLength' => 8,
'operators' => [ 'equals', 'not_equals', 'empty', 'not_empty' ],
];
return $types;
} );

The registry intentionally accepts only built-in declarative sanitizers and validators. Add a format-specific error through itc_forms_validation_errors, as shown in the PHP hook reference.

Register the editor descriptor before the ITC Forms bundle:

wp.hooks.addFilter(
'itcForms.builder.fieldTypes',
'acme/company-code',
( types ) => ( {
...types,
company_code: {
key: 'company_code',
label: 'Company code',
control: 'input',
inputType: 'text',
operators: [ 'equals', 'not_equals', 'empty', 'not_empty' ],
},
} )
);

Use WordPress i18n for production labels. Preserve the field key once forms have been saved, add server-focused normalization and validation tests, and verify entry, privacy export, CSV, conditional logic, and delivery behavior.