Created
September 2, 2021 19:12
-
-
Save elpuas/7287f36e33aa1e8eed726f038922a7a9 to your computer and use it in GitHub Desktop.
Modified Fields Front End
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
add_filter( 'gform_pre_render', 'twentytwentyone_gf_add_placeholder' ); | |
add_filter( 'gform_pre_validation', 'twentytwentyone_gf_add_placeholder' ); | |
add_filter( 'gform_pre_submission_filter', 'twentytwentyone_gf_add_placeholder' ); | |
function twentytwentyone_gf_add_placeholder( $form ) { | |
if ( $form['id'] !== 1 ) { | |
return; | |
} | |
$fields = $form['fields']; | |
foreach( $fields as $field ) { | |
if ( $field->type === 'select' && $field->label === 'State' ) { | |
$field->placeholder = 'Select a State'; | |
$field->isRequired = true; | |
} | |
var_dump( $field ); | |
} | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment