Last active
December 27, 2019 06:38
-
-
Save mishterk/4442055ee0d814c36381bfc50295e868 to your computer and use it in GitHub Desktop.
Calculated field enhancements in Advanced Forms Pro version 1.6.6. For more info see https://hookturn.io/2019/11/advanced-forms-pro-calculated-field-enhancements/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will intercept the rendered calculated field and insert the markup | |
// into an element with the id `#preview-container` | |
acf.addAction( 'af/field/calculated/value_updated', function( value, field, form ) { | |
$('#preview-container').html(value); | |
}); | |
// You may intercept the return values of specific fields by field name | |
acf.addAction( 'af/field/calculated/value_updated/name=FIELD_NAME', function( value, field, form ) { | |
// … | |
}); | |
// You may also intercept the return values of specific fields by field key | |
acf.addAction( 'af/field/calculated/value_updated/key=FIELD_KEY', function( value, field, form ) { | |
// … | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is the simplest format available and will trigger the update for | |
// all calculated fields on the page | |
acf.doAction( 'af/field/calculated/update_value' ); | |
// You may target specific fields by field name | |
acf.doAction( 'af/field/calculated/update_value/name=FIELD_NAME' ); | |
// You may also target specific fields by field key | |
acf.doAction( 'af/field/calculated/update_value/key=FIELD_KEY' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment