Last active
September 2, 2021 19:15
-
-
Save elpuas/e92bcd494cda12486ebcfa2404103f90 to your computer and use it in GitHub Desktop.
Update Forms Everywhere
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
function twentytwentyone_gf_add_placeholder() { | |
$forms = GFAPI::get_forms(); | |
foreach ( $forms as $form ) { | |
if ( $form['id'] !== 1 ) { // Or Any Form ID | |
return; | |
} | |
$fields = $form['fields']; | |
foreach( $fields as $field ) { | |
if ( $field->type === 'select' && $field->label === 'State' ) { | |
$field->placeholder = 'Choose a State'; | |
$field->isRequired = true; | |
} | |
} | |
$result = GFAPI::update_form( $form ); | |
} | |
return $result; | |
} | |
twentytwentyone_gf_add_placeholder(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment