How to override a field placeholder when rendering an AC form

Created by Phil Kurth, Modified on Mon, 4 Jul, 2022 at 3:43 PM by Phil Kurth

To modify a field's placeholder when rendering an ACF form, you may use the af/field/before_render filter. This filter provides an opportunity to modify the field array before a form is rendered.


add_filter( 'af/field/before_render', function ( $field, $form, $args ) {
  // If we need to run this only on a specific form, check for the form key.
  if ( $form['key'] !== 'YOUR_FORM_KEY_HERE' ) {
    return $field;
  }

  // Set the placeholder on a specific field.
  if ( $field['name'] === 'email' ) {
    $field['placeholder'] = 'Enter your email address';
  }

  return $field;
}, 10, 3 );

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article