Search

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 fieldfor this. The issue is that the fields contains mixed options (some 'static', some with their own selectbox referencing other sections' entries):

For example:

Contact us for:
[ ] General questions
[ ] Complaints about [ - Employee John - | v ]
[ ] Complaints about [ - Product X - | v ]
[ ] The amazing FooBarBazzer™

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) and request-info2 (1st dynamic option list) etc) but maybe there's a better way?

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.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details