Last active
March 28, 2023 22:54
-
-
Save kjohnson/3f0c0ecefd9da1398808b5b13abb911f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| /** | |
| * Update list options during form render. | |
| * | |
| * @param array $options [ [ label, value, calc, (bool) selected, etc ], ... ] | |
| * @param array $settings | |
| */ | |
| add_filter( 'ninja_forms_render_options', function( $options, $settings ) { | |
| $options[] = [ | |
| 'label' => 'New Option', | |
| 'value' => 'new', | |
| 'calc' => 0, | |
| 'selected' => true | |
| ]; | |
| return $options; | |
| }, 10, 2 ); |
This file contains hidden or 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
| <?php | |
| /** | |
| * Update list options during form render. | |
| * | |
| * @param array $options [ [ label, value, calc, (bool) selected, etc ], ... ] | |
| * @param array $settings | |
| */ | |
| add_filter( 'ninja_forms_render_options', function( $options, $settings ) { | |
| $options_before[] = [ | |
| 'label' => 'Before', | |
| 'value' => 'before', | |
| 'calc' => 0, | |
| 'selected' => true | |
| ]; | |
| $options_after[] = [ | |
| 'label' => 'After', | |
| 'value' => 'after', | |
| 'calc' => 0, | |
| 'selected' => false | |
| ]; | |
| return array_merge( $options_before, $options, $options_after ); | |
| }, 10, 2 ); |
This file contains hidden or 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
| <?php | |
| /** | |
| * Update country list options during form render. | |
| * | |
| * @priority >10 After the Country List is populated. | |
| * | |
| * @param array $options [ [ label, value, calc, (bool) selected, etc ], ... ] | |
| * @param array $settings | |
| */ | |
| add_filter( 'ninja_forms_render_options_listcountry', function( $options, $settings ) { | |
| return $options; | |
| }, 11, 2 ); |
This file contains hidden or 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
| <?php | |
| /** | |
| * Update list options during form render. | |
| * | |
| * @param array $options [ [ label, value, calc, (bool) selected, etc ], ... ] | |
| * @param array $settings | |
| */ | |
| add_filter( 'ninja_forms_render_options', function( $options, $settings ) { | |
| foreach( $options as &$option ) { | |
| if( 'two' == $option[ 'value' ] ){ | |
| $option[ 'selected' ] = true; | |
| } else { | |
| $option[ 'selected' ] = false; | |
| } | |
| } | |
| return $options; | |
| }, 10, 2 ); |
This file contains hidden or 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
| <?php | |
| /** | |
| * Update list options during form render. | |
| * | |
| * @param array $options [ [ label, value, calc, (bool) selected, etc ], ... ] | |
| * @param array $settings | |
| */ | |
| add_filter( 'ninja_forms_render_options', function( $options, $settings ) { | |
| return $options; | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added options aren't being submitted, not even being recorded in the submission.