I have a form that is dynamically generated. Containing recurring lists of hidden fields, that represent selections within my application.
A form would typically look something like this:
<form>
<fieldset>
<input type="hidden" name="key1" value="value1"/>
<input type="hidden" name="key1_option" value="option1"/>
</fieldset>
<fieldset>
<input type="hidden" name="key2" value="value1"/>
<input type="hidden" name="key2_option" value="option2"/>
</fieldset>
</form>
Is there a better way to do something like this?
The main difficulty I am facing is that you lose the logical grouping of the fieldsets when you submit the form and try to interpret the input on the backend.
The logic behind the HTML structure will be lost of course, the only information transmitted is what’s inside the form-tag. But I guess you already know that.
Why don’t you use arrays to name your variables?
Is there a reason you group your items like that?