Is there a way to add id, name and title attributes to hidden fields? It seems the only option available is the value attribute.
Is there a way to add id, name and title attributes to hidden fields? It seems the only option available is the value attribute.
The hidden field already has an id and name which can be found on the title bar of the fields properties panel when hovered over or opened, as an example the id is formatted as 'input_1_6' and the name is 'input_6', the 1 represents the form id which can be found by hovering over the form settings panel at the top of form editor. You could add the title attribute by using jquery and something like this
$('#input_1_6').attr('title', 'i am a hidden field');
Do you have a complete code example for me? Something to copy/paste?
@leanderb, can you please post a link to the page on your site where the form is embedded? Also, please ask what you would like to do with your form exactly. Thank you.
Hey Chris,
sure thing, sorry:
I need the form to act within a payment process and pass along some custom, hidden variables. When I read the output of the shortcode-embedded Gravity Form, there is a correct (default) value presented but the name is overwritten with ing something like "input_5". That is not sufficient for my needs. See code:
<li id="field_1_5" class="gfield gform_hidden">
<input id="input_1_5" class="gform_hidden" type="hidden" value="rdstnz" name="input_5">
</li>
<li id="field_1_6" class="gfield gform_hidden">
<input id="input_1_6" class="gform_hidden" type="hidden" value="Mitgliedsaccount-Er-distanziert-sich" name="input_6">
</li>
<li id="field_1_7" class="gfield gform_hidden">
<input id="input_1_7" class="gform_hidden" type="hidden" value="100" name="input_7">
</li>
Live: http://www.er-distanziert-sich.info/bestellen (temporary, I am editing this page currently)
I am unaware of how to write my own JQuery-Code and have not succeeded in coating the above $('#input_1_6').attr('title', 'i am a hidden field'); properly. I'd either like to use a fully written and working code-sample or maybe a hint at another option.
Thanks so much!
leanderb, your issue is completely unrelated to the issue which was originally asked here.
You can't change the id of a hidden field without breaking Gravity Forms. How are you sending your data to the payment processor? Can you share you code here?
So far, nothing you want to do is related to jQuery that I can see.
Hey Chris,
sorry if things got mixed up, that wasn't my intention. But since richardvav is also talking about changing the name of a hidden form field from default to another value, I guessed to be right with my question.
If there is no way to add custom names to hidden form fields (original question by rnewman) how can I manage to work around that? I tried the approach presented by richardvav, but couldn't follow along...
rnewman was looking to add id, name and title attributes to the fields, which can be accomplished as richardvav explained, using jQuery. That is adding additional attributes to existing fields. richardvav technically did not address adding the name, since the name is already present and is how the jQuery would know to target that element.
It sounds to me like you actually want to change the name of the field from input_7, correct? If you actually need the names of the input changed, you won't be able to do that and not break Gravity Forms. Gravity Forms requires that those input ID be in the format as it was output.
Can you share more information about what you actually need to send, and to where? Maybe there is a way using the gform_after_submission hook. Without more details from you, it's difficult to help you achieve your goal.
My bad. Yeah, I want to change the name of the field from say 'input_5' to 'project' because this is the variable needed when passing on the info to my payment provider. There they grab those additional parameters and pass them back to my site after payment has been made out.
It is tricky, because I have to have those parameters entered BEFORE payment as they are expected to be already set for the membership-plugin registration-process afterwards.
Regarding the gform_after_submission hook: Would the code go into my theme's functions.php? Sorry, the documentation skipped that part for one is expected to have that covered I guess.
Yes, the code will go in your theme's functions.php.