Created
November 7, 2017 21:46
-
-
Save davecurrierseo/af3f84bb1de4f543dbfabd4a73a1be16 to your computer and use it in GitHub Desktop.
Add Form Name as a Data Attribute to Gravity Forms Form Element
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
/** | |
* Adds form title to a data attribute on the form element | |
* @param [string] $form_tag The string containing the <form> tag | |
* @param [object] $form The current form | |
* @return [string] The new <form> tag string | |
*/ | |
function gravity_form_tag($form_tag, $form) { | |
$form_title = $form['title']; | |
$form_tag = str_replace('<form', "<form data-formtitle='{$form_title}'", $form_tag); | |
return $form_tag; | |
} | |
add_filter('gform_form_tag', 'gravity_form_tag', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment