Custom form - how to retain field values on error

Hi there,


I've set up a custom form that uses radio buttons and check boxes. When the form is submitted and an error message is generated (in this case because there are mandatory fields that haven't been completed), the values of the radio buttons (where no default value has been set) and all checkboxes are lost.



How can we retain the values of the radio buttons and checkboxes that have been filled in when an error message is generated?



Updated: The form in question uses custom body copies for the form page and thank you page. I've just had a look at a form that uses %form_contents% instead, and it works the way it should (i.e. retains radio button and checkbox values). What needs to be put into a custom body copy to make it work the same way?



Updated (again): I've just done a bit more experimentation. If I put the form field for the checkbox list into the custom body copy for the form using the single keyword for the checkbox list (e.g. %question_field_57447_q2%) it works fine. Looking at the source code, I can see that it's putting 'checked="checked"' for any boxes that have been ticked.



However, I need to put the checkboxes into a table, so I need a little more control over the formatting of the list (I don't want them in the default layout which is an unorded list, nor do I want to use the labels as they are). To do this, I have used the checkbox fields themselves in the custom body copy (e.g. <input type="checkbox" name="q57447:q2" id="q40500:q2_0" value="0" class="sq-form-field" />, <input type="checkbox" name="q57447:q2" id="q57447:q2_1" value="1" class="sq-form-field" />, etc). When I do this, it won't retain any of the values entered into these fields when an error message is generated.



Is there some value or variable I can put into the checkbox fields so that checked boxes remain checked when an error is generated (i.e. inputs "checked" into the code for the field if it has been checked)? e.g. <input type="checkbox" name="q57447:q2" id="q40500:q2_0"value="0" class="sq-form-field" VALUE IF CHECKED/VALUE IF NOT CHECKED />.



Updated (for a third time!) I've just uploaded a PDF that shows how/why we need to use the checkboxes in a table.
spot_5_im.pdf (28.3 KB)

Edited because it was pointed out that I was being slightly too gnomic for a Monday:


Because you're building your own form input fields, Matrix has no way of adding a "checked" attribute to your manually created fields. There are no keywords for this at present. You would have to get custom development for this.

So the only option for checkboxes is to have them in an unordered list? :o

[quote]So the only option for checkboxes is to have them in an unordered list? :o
[right][post=“9129”]<{POST_SNAPBACK}>[/post][/right][/quote]



I believe so. Again, you’d need to speak to the Development Team to get this changed.

Is there some other way to do what we’re trying to do then (see uploaded example). Basically, it’s an order form. The items that can be ordered are best presented in a table, rather than an unordered list.


Only being able to have a set of checkboxes or radio buttons in an unordered list seems very limiting to me.

[quote]Is there some other way to do what we’re trying to do then (see uploaded example). Basically, it’s an order form. The items that can be ordered are best presented in a table, rather than an unordered list.
[right][post=“9131”]<{POST_SNAPBACK}>[/post][/right][/quote]



I know we’ve developed order forms based off the Custom Form before, but I’m not sure how. I’ll try and prod one of the other implementers in here to reply.