Dynamic form fields in Squiz Custom Forms


(Jason Collier) #1

Matrix Version: 5.4.7.1

I’m looking into dynamically adding form fields when users click an ‘add’ button. I’ve tried adding a content container (raw html) to the Bodycopy - Page Content page which achieves the desired effect of duplicating an input field, but on form submission, the duplicate fields are not included on the default thank you page or recipient email.

Where should I be putting the JavaScript and what do I have to put in the JavaScript or do with matrix to recognise and post the dynamically generated fields?

Any help would be greatly appreciated!


(John gill) #2

A matrix form doesn’t accept any submitted values that don’t correspond to a Question that already exists on the form asset. So if you wanted users to be able to to “duplicate” fields up to a maximum of say 10, then your form would need to have 10 matching Questions set up to receive the submitted values.

Alternatively, you could have a hidden field and use JavaScript to serialize multiple form fields into a single Question, but obviously then you’re throwing away a lot of functionality (validation etc).


(Jason Collier) #3

So I’d be using JavaScript to hide the additional questions created in matrix and show each one as required. Thanks JohnGill!