Created
October 27, 2025 20:43
-
-
Save rickalday/0eed7270be45499a8d1c6c147cc16840 to your computer and use it in GitHub Desktop.
Create a year dropdown field in a GiveWP form
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 | |
| function getYears(): array | |
| { | |
| $startYear = 1970; | |
| $currentYear = date('Y'); | |
| return range($startYear, $currentYear); | |
| } | |
| add_action('givewp_donation_form_schema', static function (Give\Framework\FieldsAPI\DonationForm $form) { | |
| $field = Give\Framework\FieldsAPI\Select::make('grduation_year') | |
| ->options(...getYears()) | |
| ->emailTag('graduation_year'); | |
| $form->insertAfter('email', $field); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment