8 users online. Create an account or sign in to join them.Users

Search

Hello,

I am currently building a form with Symphony and it works but there’s one thing I simple can’t seem to get my head around:

How can I populate a select box with a number of static options in my front end?

This is my code so far:

<select name="fields[accommodation-type]">
    <option value="{events/sign-up/post-values/accommodation-type}"></option>
</select>

I’ve already spent a while reading on this forum, but to no avail.

If someone could point me in the right direction, I’d be very grateful!

Thanks…

For your option to show up, you’ll need to <option>Put some text here</option>.

If you’ve specified the static options in the back end, may I suggest building your forms using Nick’s Section Schemas and Form Fields extensions and xslt? I’ve not got round to implementing this yet, but reading through it, it is very good stuff…

Symphony doesn’t provide an out of the box way of achieving this, so I created an extension called Section Schemas. Use the extension to create a custom Data Source (don’t worry, no PHP coding required!) that, when attached to your page, spits out your section structure (including static options) in the XML.

You would then be able to iterate over these options (using an xsl:for-each for example) to build your <option> elements, and an xsl:if for each one to write in a selected attribute if the option value matches that of the event.

After you’ve built several forms you’ll realise this is a pretty tedious job, so I wrote the Form Controls utility to make building HTML forms much easier.

Give Section Schemas a go first, as Form Controls is quite a big piece of XSLT code and is an acquired taste :-)

Hey,

Thanks for your help. Will do as suggested.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details