PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Adding Attributes to Input Tags

  1. Which filter do I use to add an attribute like 'autofocus' or 'placeholder' or 'title' to an input tag?

    i suggest a form field in the admin where you create the form that would allow you to add anything you want to the input tag. That way we could add something like this all in one field and have it appear in the tag.

    placeholder="My placeholder text" autofocus title="My Title"

    Posted 12 years ago on Friday September 2, 2011 | Permalink
  2. There have been a couple discussions of the HTML5 placeholder text:
    http://www.gravityhelp.com/forums/topic/html5-placeholder-not-working#post-23197
    http://www.gravityhelp.com/forums/topic/watermark-a-form-field

    Posted 12 years ago on Friday September 2, 2011 | Permalink
  3. Does that mean there is no way to filter a input (or label) tag to add attributes not specifically available through the admin gui?

    Posted 12 years ago on Friday September 2, 2011 | Permalink
  4. Through the form builder GUI, correct: it's not currently possible. It's something that's planned for a future release as noted in both those links I posted previously. It's possible to do what you want with jQuery, but not in the form builder admin.

    Posted 12 years ago on Friday September 2, 2011 | Permalink
  5. I understand your answer, but just to clarify my question: I was looking for a filter or hook that would enable me to add attributes through the functions.php file... not the gui. It's pretty obvious that feature is not available in the form builder admin.

    I understand the answer to that is also no so I'll revert back to my original suggestion: an input field in the form builder that would allow users to add anything extra that they wanted to the tag. That would free the developers from having to add new form fields in the gui for every new attribute requested by users.

    Absent of that, a hook would be helpful. Let me hook into the end of the tag and add anything I want.

    Thanks for your help.

    Posted 12 years ago on Friday September 2, 2011 | Permalink