html-forms
html-forms copied to clipboard
[BUG] Field count is not correct when using filter to add hidden fields
I have a form with select fields, text and textarea and a checkbox. If I dont fill out the second select fields, the form is send and saved. If I fill out the second (and or third) select field, the form is not send, nor saved but it shows that it should have been send.
This is the XHR request
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="_hf_form_id"
970
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="_hf_h970"
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="anrede"
Herr
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="Vorname"
Myname
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="Nachname"
Mylastname
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="Telefon"
1234567890
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="E-Mail"
[email protected]
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="message"
TEST
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="interesse"
Kontakt
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="aufmerksam"
Flyer
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="datenschutz"
accepted
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="contactperson"
Contact Person
Name and Info
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="project_id"
892020230
-----------------------------76428871927723695161012850816
Content-Disposition: form-data; name="pid"
600
-----------------------------76428871927723695161012850816--
The response
{"message":{"type":"success","text":"Vielen Dank! Wir werden uns in K\u00fcrze melden."},"hide_form":true}
Server is running PHP 7.3 and input vars are set to 3000. So this shouldnt be a problem.
Sooo.. after a long time of debugging, I found the error or the fix!
add_filter( 'hf_validate_form_request_size', false );
helps for the moment!
The problem is obviously the counting of the fields 2 hidden fields are added dynamically via filters (depending if they have a value from the post)
So this should be investigated!
-- After further investigation it seems the field count check is faulty. When select fields are not chosen, then they are not send as postdata and the count was correct. I couldn't test if the function correctly counts the final markup with the dynamically added hidden fields.
Please test this and correct it or document the filter. Thanks
Wow, is this how you maintain an active plugin? This bug is serious and not even 1 reply within a week!
It you start being rude, do not think I will bother trying to help you… Maybe consider I might have other pressing matters in my life that required my attention in the past few days?
Op 2 nov. 2021 om 21:41 heeft despecial @.***> het volgende geschreven:
Wow, is this how you maintain an active plugin? This bug is serious and not even 1 reply within a week!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
First up, this is what you call being „rude“? I was wondering that the owner of the script doesn’t even reply for a bug report within a week. And I didn‘t say it has to be fixed for me.
I was the one trying to help. I reported. I investigated and I even gave a temporary solution for your product. Which is also a commercial one if I understand the website‘s text.
So this is a really weird way to reply to someone who is helping to improve your product and even takes the time and effort for that
just think about how you communicate with others. No offense.
Tested this with the following form HTML and adden hidden fields, but was unable to reproduce the issue. The field count already takes added fields through the filter into account.
<p>
<label for="form-with-spaces-in-name-attributes-VOORNAAM">Voornaam</label>
<input type="text" name="VOORNAAM" id="form-with-spaces-in-name-attributes-VOORNAAM" />
</p>
<p>
<label for="form-with-spaces-in-name-attributes-ACHTERNAAM">Achternaam</label>
<input type="text" name="ACHTERNAAM" id="form-with-spaces-in-name-attributes-ACHTERNAAM" />
</p>
<p>
<label for="form-with-spaces-in-name-attributes-TELEFOON">Telefoon</label>
<input type="text" name="TELEFOON" id="form-with-spaces-in-name-attributes-TELEFOON" />
</p>
<p>
<label for="form-with-spaces-in-name-attributes-EMAIL">Email</label>
<input type="email" name="EMAIL" id="form-with-spaces-in-name-attributes-EMAIL" />
</p>
<p>
<label for="form-with-spaces-in-name-attributes-INTERESSES">Interesses</label>
<select name="INTERESSES2" id="form-with-spaces-in-name-attributes-INTERESSES"><option>One</option><option>Two</option></select>
</p>
<p>
<label >Interesses</label>
<select multiple="true" name="INTERESSES">
<option>One</option><option>Two</option>
</select>
</p>
<p>
<label for="form-with-spaces-in-name-attributes-HOBBIES">Hobbies</label>
<label><input type="checkbox" name="HOBBIES[]" value="One" /> <span>One</span></label><label><input type="checkbox" name="HOBBIES[]" value="Two" /> <span>Two</span></label>
</p>
<p>
<input type="submit" value="Send" />
</p>
add_action( 'hf_form_markup', function($str) {
$str .= '<select name="MY_SELECT"><option></option><option>One</option><option>Two</option></select>';
$str .= '<input type="hidden" name="hidden_1" value="foo" />';
$str .= '<input type="hidden" name="hidden_2" value="foo" />';
return $str;
});