-
-
Save dexit/867bc12dc8fa6b06bd793cb30828e914 to your computer and use it in GitHub Desktop.
Elementor Pro Form Prepopulate Select Field in two forms (One on a page and one on a popup)
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 | |
| // render elementor forms select item for year_built in Angebotsanfrage form | |
| // rerender the select field using elementor form api | |
| add_filter('elementor_pro/forms/render/item/select', function($item, $index, $form) { | |
| if('vehicle_quote_form' === $form->get_settings_for_display('form_name') || 'vehicle_quote_form_popup' === $form->get_settings_for_display('form_name')) { | |
| if('year_built' == $item['custom_id'] || 'year_built_popup' == $item['custom_id']) { | |
| $item['field_options'] = "Bitte Jahr auswählen|\n"; | |
| for($year=date('Y'); $year >= 1970; $year--) { | |
| if($year != 1970) { | |
| $item['field_options'] .= $year . "|" . $year . "\n"; | |
| } else { | |
| $item['field_options'] .= $year . "|" . $year; | |
| } | |
| } | |
| } | |
| } | |
| return $item; | |
| }, 10, 3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment