Skip to content

Commit 80e0031

Browse files
dariospacespivurno
andauthored
Create gppa-add-a-custom-choice-template-to-choices.php (#446)
* Create gppa-add-a-custom-choice-template-to-choices.php added hook * Update gppa-add-a-custom-choice-template-to-choices.php fixed phpcs errors * Update and rename gppa-add-a-custom-choice-template-to-choices.php to gppa-add-a-custom-choice-template.php Co-authored-by: David Smith <[email protected]>
1 parent a63cb60 commit 80e0031

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* Gravity Perks // Populate Anything // Add A Custom Choice Template
4+
* https://gravitywiz.com/documentation/gravity-forms-populate-anything/
5+
*
6+
* Choice templates allow you to map data to different properties of your Gravity Forms choices. In this example, we
7+
* demonstrate how to create a new template for a theoretical "image" choice property. With this in place, you would
8+
* be able to select a value in the Populate Anything choices UI that is mapped to the "image" property for each choice.
9+
*/
10+
add_filter( 'gppa_input_choice', function( $choice, $field, $object, $objects ) {
11+
$choice['image'] = gp_populate_anything()->process_template( $field, 'image', $object, 'choices', $objects );
12+
return $choice;
13+
}, 10, 4 );

0 commit comments

Comments
 (0)