Version 1.9.3 is now live for both Advanced Forms and Advanced Forms Pro. The main focus for this release is to improve calculated fields in ACF forms to make them more flexible but there are a number of other small fixes including a hot-fix for ACF’s core validation which prevent validation problems when using more than one form on the same page. Details on these enhancements are below.
Improve performance of calculated fields by reducing to a single AJAX call
Prior to this release, each calculated field in a form would fire its own AJAX call back to the server to calculate the updated value. When using multiple calculated fields, this could slow down a form and unnecessarily add to server resource usage. Now, whenever a change is detected on a form, a single AJAX request is sent to compute all calculated fields at once.
Add support for aggregate calculated fields
Due to the way calculated fields were handled before this release, it wasn’t possible to use one calculated field inside the calculation of another as they were all computed asynchronously using the pre-calculated form values. Now that calculated fields are all handled in a single AJAX request, it’s possible to aggregate these into compound calculations.
Add the ability to control the order in which calculated fields are computed
During a calculation request, calculated fields are traditionally handled in the order they appear in the form. This release makes it possible to control the order of calculation by dragging and dropping the fields in order in the form settings screen. This comes with the advantage of being able to have aggregate calculated fields in any order and maintain correct calculations. E.g; a summary showing all field values (including other calculated field values) could be added to the top of a form as long as it is moved to the bottom of the calculation order.
Prevent the field name and other settings from disappearing in ACF field group settings
The field name and other field settings will no longer disappear when selecting the calculated field type in an ACF field group’s settings page. This allows full control to set and modify the field name that is used in both form merge tags and calculation PHP filter hooks.
Show UI notices indicating when a calculated field setting is being modified by a hooked PHP function
Hooked PHP functions give the most flexibility for computing the output of a calculated field but prior to this release, it’s been impossible to tell whether a field is potentially being overridden by a hooked function without looking at the code. Now, if a field has a PHP function hooked using the field’s name (af/field/calculate_value/name=NAME
) or ACF field key (af/field/calculate_value/key=KEY
) a notice will appear below the field label.
Additionally, if the global variant of the filter is in use — af/field/calculate_value
— it could potentially modify and/or override all calculated fields. In this situation, a notice is shown above the calculated field settings stack.
Add a hot fix for ACF form validation
When using more than one form on a single page, ACF runs the validation on every single field it finds when one form is submitted. This results in issues when using more than one form on a single page with validation on each.
This release ships with an additional script that patches the JavaScript on the fly in order to limit the scope of fields being validated to those that are in the form being submitted. This script is automatically enqueue but should it need to be disabled for any reason, the following snippet can be used:
Changelog
- Added the
af_render_content
private field type for internal use in form settings UI. - Added a hotfix for ACF validation bug when using multiple forms on the one page.
- Added the
af/settings/enqueue_validation_hotfix
filter for disabling the validation hotfix. - Fix deprecation notices related to admin page registration that occur in PHP 8.1.
- Fix deprecation notices related to dynamic property usage in PHP 8.2.
Pro
- Changed user/post editing order to edit user before post. This allows the use of the user ID during post creation/editing.
- Improved calculated fields to use a single AJAX request for an entire form. This improves performance and reduces the number of requests.
- Added support for aggregate calculated fields. It is now possible to use the result of a calculated field in another calculated field.
- Changed calculated field rendering so that field name and description are no longer hidden in the field group settings.
- Changed internal field type for calculated field admin to have
af_
prefix. Renamed class toAF_Calculated_Admin_Field
. - Added ability to control the order in which calculated fields are computed. This facilitates using aggregate calculated fields anywhere in a form.
- Added admin notice to calculated field when a filter is in use for the field name or key. e.g;
af/field/calculate_value/name={field_name}
oraf/field/calculate_value/key={field_key}
. - Added admin notice to calculated field settings tab indicating when the generic
af/field/calculate_value
filter in in use.