Skip to content

Commit 3053ec0

Browse files
authored
gw-list-field-as-choices.php: Added snippet usage examples from gw-list-field-as-choices-usage.php.
1 parent cd558da commit 3053ec0

File tree

2 files changed

+54
-65
lines changed

2 files changed

+54
-65
lines changed

gravity-forms/gw-list-field-as-choices-usage.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

gravity-forms/gw-list-field-as-choices.php

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,57 @@ function is_applicable_field( $field ) {
154154
*/
155155

156156
# Basic Usage
157-
# new GW_List_Field_As_Choices( array(
158-
# 'form_id' => 1,
159-
# 'list_field_id' => 2,
160-
# 'choice_field_ids' => 3
161-
# ) );
157+
//new GW_List_Field_As_Choices( array(
158+
// 'form_id' => 1,
159+
// 'list_field_id' => 2,
160+
// 'choice_field_ids' => 3,
161+
//) );
162+
163+
164+
# Enable Sorting of Choices Alphanumerically
165+
//new GW_List_Field_As_Choices( array(
166+
// 'form_id' => 1,
167+
// 'list_field_id' => 2,
168+
// 'choice_field_ids' => 3,
169+
// 'sort' => true,
170+
//) );
171+
172+
# Populating Multiple Choice Fields
173+
//new GW_List_Field_As_Choices( array(
174+
// 'form_id' => 384,
175+
// 'list_field_id' => 3,
176+
// 'choice_field_ids' => array( 6, 7 ),
177+
//) );
178+
179+
180+
# Customizing the Choice Label and Value
181+
//new GW_List_Field_As_Choices( array(
182+
// 'form_id' => 384,
183+
// 'list_field_id' => 2,
184+
// 'choice_field_ids' => array( 4, 5 ),
185+
// 'label_template' => '{Name} <span style="color:#999;font-style:italic;">({Age})</span>',
186+
// 'value_template' => '{Name}',
187+
//) );
188+
189+
# Filter Usage
190+
## Customize List field values to be populated as choices based on Gravity Flow User Input step.
191+
//add_filter( 'gwlfac_list_field_values', function( $values, $form, $args ) {
192+
// if ( is_array( $values ) ) {
193+
// return $values;
194+
// }
195+
196+
# Confirm we are within a Gravity Flow Inbox.
197+
// if ( rgget( 'lid' ) && rgget( 'page' ) == 'gravityflow-inbox' ) {
198+
// $entry = GFAPI::get_entry( (int) rgget( 'lid' ) );
199+
// // Verify the entry list field has previously stored values to use.
200+
// if ( $entry ) {
201+
// $values = unserialize( $entry[ $args['list_field_id'] ] );
202+
// if ( ! is_array( $values ) ) {
203+
// return false;
204+
// } else {
205+
// return $values;
206+
// }
207+
// }
208+
// }
209+
// return false;
210+
//}, 10, 3 );

0 commit comments

Comments
 (0)