Basic usage

Table of Contents

Calculated fields adds a new setting “Formula” to the the ACF field editor. When the post is saved to the database, the field value is the result of evaluating the formula expression. The real power of the expression comes from the ability to use other fields as variables in the expression.

A formula can contain the basic mathematical operations: plus (+), minus (-), multiply (*), division (/) and power of (^). Formulas can also contains functions like sin, cos, arcsin, log, ln, sqrt, abs. Parentheses are supported.

Updating and Ajax #

The main or core functionality of Calculated Fields for ACF is to evaluate the formula expressions at the time when the post is saved to the database. To make life as easy as possible for the administrator, Calculated Fields for ACF goes to great lengths to also update calculated fields in real time during the time of editing the post. This updating is managed using Ajax calls, so the actual calculations are always performed in PHP on the server side.

The Ajax based updating “just works” when editing posts custom fields in any of the normal meta boxes, regardless if these are displayed in the classic editor or in the block editor (Gutenberg).

The Ajax updating also “just works” in a few, but far from all, front end scenarios. We are actively supporting front end calculated fields when the front end forms are created using the built in “acf_form” from Advanced Custom Fields and with the ACF Elementor addon.

More reading

Powered by BetterDocs

Leave a Reply

Your email address will not be published. Required fields are marked *