Mixed dynamic Selectboxfield options in form.
This is an open discussion with 10 replies, filed under General.
Search
Does this need to be a select box at all? If it's a contact form then it sounds like a one-time data input. So the data storage could be a text input, but render as a <select>
on the frontend using XSLT (where you can use data sources to build a list of employees and products).
My thinking is that if the "Contact us for" never needs to change once the form is submitted, and the submission is coming from a frontend event, just store as a plain text input.
I see. That would indeed be simpler.
But: it means hardcoding the options in the XSL template, no?
It's not very accessbile but when the options are defined in a selectbox field they are at least 'somewhat' editable in the CMS…
But: it means hardcoding the options in the XSL template, no?
If the values are stored in a section, you can create a data source that you use to create the options.
True. Thanks. It seems the simpler solutions are best (as most always :) ).
render as a on the frontend using XSLT (where you can use data sources to build a list of employees and products)
Yep, I was assuming that Employees and Products were already data in sections.
the dynamic options would obviously already be entries in Sections, but the above solution would require a ('configuration-') section be created for the static options with the only purpose of making these static option strings editable in the Admin.
I think I might go with the simplest solution: add a simple textfield for the value and just hardcode the static form options in the template. I can then use DS'es for the dynamic options.
oh snap: I just realize I need these options to be multiple: so how do I add the selected options to one (1) textfield?
Have you thought about using a tag list field?
Nope. How would that work?
I see how that would make it easier to fill the (static!) options in the Admin, but that leaves me with the mixed-in-dynamic-options™ challenge. Plus: I would not know a.t.m. how to fill a tagfield from hardcoded options. If the latter is easy/possible it would be a better field-candidate.
("Hey! Maybe I could mis-use nested (tabbed) SSM's for this…" - just kidding! :D )
Shouldn't something like this work?
<input type="checkbox" name="fields[taglist][]" value="Static Value" /> <xsl:for-each select="my/dynamic/options"> <input type="checkbox" name="fields[taglist][]" value="Dynamic Value" /> </xsl:for-each>
Or am I missing something essential?
hmm, this may well work. The cool thing is that I can populate a tagsfield
with multiple values of course… Thanks, I'll check it out (later, must go now).
Create an account or sign in to comment.
I am recreating a simple contactform from a Joomla site to the new Symphony site (yay me!).
The form is fairly straightforward but one part contains a set of checkboxes with various options ("Contact me for:" 'foo', 'bar', 'baz' stuff).
I was thinking about using the vanilla
selectbox field
for this. The issue is that the fields contains mixed options (some 'static', some with their own selectbox referencing other sections' entries):For example:
Listing static options (such as "General questions") seems easy. Mixing these with other options that contain dynamic selectboxes referencing other sections: not so much…
What would be a good way to approach this? I could split the options and create seperate fields for the dynamic options (
request-info1
(static options list) andrequest-info2
(1st dynamic option list) etc) but maybe there's a better way?