This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
Apply this filter to enforce calculation during server-side validation. It is disabled by default.
- Calculations that use repeated values, or calculation fields in a repeater.
- .toFixed()
- [age] / [date_calc] shortcodes
- Ternary expressions that involve ? and : characters.
- Any shortcode options like show="value" / show="label".
Usage
add_filter( 'frm_force_calculation_on_validate', 'force_calculation_on_validate', 10, 2 );
Parameters
- None
Examples
Only force text calculations
add_filter( 'frm_force_calculation_on_validate', function( $force, $field ) {
$force = 'text' === $field->field_options['calc_type'];
return $force;
}, 10, 2 );
Force only specific field IDs
add_filter( 'frm_force_calculation_on_validate', function( $force, $field ) {
$ids_to_force = array( 3852 );
$force = in_array( (int) $field->id, $ids_to_force, true );
return $force;
}, 10, 2 );
Force calculations on validation
add_filter( 'frm_force_calculation_on_validate', '__return_true' );