Skip to content

Instantly share code, notes, and snippets.

@elpuas
Created September 2, 2021 19:12
Show Gist options
  • Save elpuas/7287f36e33aa1e8eed726f038922a7a9 to your computer and use it in GitHub Desktop.
Save elpuas/7287f36e33aa1e8eed726f038922a7a9 to your computer and use it in GitHub Desktop.
Modified Fields Front End
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