Can I use a DB data record set in a custom form question?

Just wondered in anyone has already tried this and if its possible, before I start working on it.


I have a DB Data Source, that lists 100 data source record sets from a Database (and which may change slightly over time).

I'd like to use an asset list of these data source record sets to create a drop down for a question in a custom form.



On submission the custom form will have a Form Submission Action to take the responses from the questions and use them in a DB query.



So, can I customise the body copy for my custom form, and somehow nest my asset listing of the 100 data source record sets to be the responses for a question on the form? Will that work? Has anyone done this sucessfully?



I'm sure there must be a way of having dynamically generated questions fed from a DB, so if you have a better idea of how to achieve this, would love to hear your thoughts!



Thanks everyone,

Charlie.

Yes, I have done this method, but with asset builders. Just make sure that you build a real select field in your custom form, add the keywords then preview your page. Then match the id, name etc from that field exactly when building your asset listing select. Then, just replace the keyword with your nested listing.


There are some limitations to this method however.

Hi Nic - I've got that bit working, like you said using some asset listings and nesting those into my customised bodycopy.
The form is looking pretty good now, but the next bit - using the form responses to run a SQL query and display the results, isn't going so well, and I'm thinking that I'm using the wrong approach using a custom form.



I've tried putting a form submission action on my form, but really I want it to go to a seperate asset listing page, and to list the results of the query with various bits of information about them.



I'm going to look at Triggers next but if you have a whole different, and better, way of doing this, do let me know!

Thanks again,

Charlie.

hmm… spoke too soon!
The form looks great, all the values are there, and from what I can see the dropdowns are identical to how Matrix would have made them from the keywords - but the responses don't carry across to the Thank you page.

I've got a couple of normal questions and those responses carry across with no problems, but the three that I created with my asset lists won't show up as responses in the form summary.



Here's the code from my coded dropdowns, with the <options> coming from an asset listing:



<select name="q52622:q2" id="q52622_q2" class="sq-form-field"><option>&nbsp;Any&nbsp;</option>

<option value="A - Enabling Access">A - Enabling Access</option>

<option value="AH - Archaeological Heritage">AH - Archaeological Heritage</option>





Looks identical to the <select> that Matrix writes out from a keyword for another question:



<select name="q52622:q4" id="q52622_q4" class="sq-form-field"><option value="">&nbsp;Any&nbsp;</option><option value="Completed">Completed</option>





Did you get your asset-list built dropdowns to carry the response across correctly Nic?



Thanks,

Charlie.

Now that I think of it, it looks like I used a normal text field for the custom form field rather than a select. Just made sure to use the same name and ID, and it works perfectly.


In order to get a select field working like you tried, you have to have identical key and val fields as your asset listing select.

Hi Nic,
When you say identical key and value fields - do you mean that I need to create each option in the 'normal' question the same as they are from my asset listing?

If that's the case then I'm going to need a different approach, I need the options to update if the database gets updated really, so I want the options to come from my asset listing without having to re-write them anywhere.



I'll keep playing!

Thanks,

Charlie.

[quote]
When you say identical key and value fields - do you mean that I need to create each option in the 'normal' question the same as they are from my asset listing?

If that's the case then I'm going to need a different approach, I need the options to update if the database gets updated really, so I want the options to come from my asset listing without having to re-write them anywhere.

[/quote]





Yes, in my testing, to get those values to get submitted, you have to create a select field in the custom form and mirror each field that is coming from your asset listing. So, like you said, it really defeats the purpose.

another option - if you don't actually need the data to be saved in the form submission asset, you can use %globals_post_whateveryourinputsarenamed% to bring the value up on the thankyou page. I think (not 100% certain) you can also access this post value if you have a trigger set up to run when the form submits.