0

I am looking to change the "other" text for a single specific field on a specific form in Gravity Forms.

It seems gform_other_choice_value does not work the way some of the other Gravity Forms filters work in that adding the form ID and field ID does not target the specific field, such as for field number 142 on form number 27 - gform_other_choice_value_27_142

How the form field currently looks enter image description here

What I need

enter image description here

The Gravity Forms documentation (https://docs.gravityforms.com/gform_other_choice_value/) shows how to change "Other" wording for all forms, but not a specific field on a specific form.

I need to target a specific field on a specific form, because I will have multiple fields of this type within this single form, as well as many different forms that use "Other" throughout the website.

(Ultimately, I would also like the "Other" field to be the first option, rather than the last, but that's the next step after this - Make "Other" the first option for a radio button field in Gravity Forms)

1
  • I am not much of a dev, so specific code examples will help much more than replies discussing general concepts. – Travis Pflanz May 21 '20 at 17:16
1

The second parameter is the field which contains the form ID to which it belongs and its own ID so you can target a specific form/field like so:

add_filter( 'gform_other_choice_value', function( $placeholder, $field ) {
    // Update "123" to your form ID and "4" to your field ID.
    if ( $field->formId == 123 && $field->id == 4 ) {
        $placeholder = 'Your custom placeholder';
    }
    return $placeholder;
}, 10, 2 );
1
  • Thanks! This works as expected. Also, tested to make sure it does work with multiple fields on the same form. – Travis Pflanz May 21 '20 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.