Search

I’m trying to get a multi select box working where multiple people could be selected at the same time. Its saving fine, but trying to recall and display who has been selected is confusing me. My variable method doesn’t seem to work for multiple items. Any help would be appreciated.

The XSL:

<select multiple="multiple" name="fields[assigned-to]">
        <xsl:for-each select="members/entry">
        <xsl:variable name="assigned-to-member" select="/single-issue/entry/assigned-to/item/@id"/>
        <xsl:choose>
        <xsl:when test="@id = $assigned-to-member">
        <option value="{@id}" selected="selected"><xsl:value-of select="name"/></option>
        </xsl:when>
        <xsl:otherwise>
        <option value="{@id}"><xsl:value-of select="name"/></option>
        </xsl:otherwise>
        </xsl:choose>
<option value="$assigned-to-member"><xsl:value-of select="$assigned-to-member"/></option>
        </xsl:for-each>
    </select>

The XML (Shortened)

<members>
        <entry id="14">
            <name handle="tina-baum">Tina Baum</name>
        </entry>
        <entry id="22">
            <name handle="fred-mcmann">Fred McMann</name>
        </entry>
    </members>
        <single-issue>
        <entry id="18">
            <assigned-to>
                <item id="14" email-hash="...">tina</item>
                <item id="22" email-hash="...">fred</item>
            </assigned-to>
        </entry>
    </single-issue>

My first guess would be

<xsl:when test="/single-issue/entry/assigned-to/item[@id = current()/@id]">

It will test if there is a node /single-issue/entry/assigned-to/item with that certain ID.

The following XSL should do it. (I prepended /data/ to the select and test for local processing.)

<select multiple="multiple" name="fields[assigned-to]">
    <xsl:for-each select="/data/members/entry">
        <xsl:variable name="id" select="@id"/>
        <option value="{$id}">
            <xsl:if test="/data/single-issue/entry/assigned-to/item[@id = $id]">
                <xsl:attribute name="selected">selected</xsl:attribute>
            </xsl:if>
            <xsl:value-of select="name"/>
        </option>
    </xsl:for-each>
</select>

Thanks so much klaftertief, your solution worked elegantly. Unfortunately I was wrong about the fact that it was already saving. I guess the Member Link Field only takes comma separated values, so I guess my idea of a multi select box is shot. I suppose I could just make it into a Tag-like field, but then I’d have to use usernames instead of real names… ::sigh::

The Member Link field really could do with being updated into a select box of Members, rather than a text input…

I wonder if that’s on the list for the upcoming release? (Which I’m sure was due with Symphony 2.1.1, or was it 2.2??)

The Member Link field really could do with being updated into a select box of Members, rather than a text input…

Except that you probably don’t want to build or go through a select box with nearly 9000 members :-)

The decision to have a Symphony 2.2 release is because of the members extension and email functionality.

I agree, a select box would be better. I submitted this as an Issue to the Members Extension. I’m a big fan of this extension and look forward to the final version.

I never thought about it with the large member numbers possibility…

I’m really looking forward to the new release, I get errors with the current one, but nothing that can’t be circumvented…

Except that you probably don’t want to build or go through a select box with nearly 9000 members :-)

I like autocompletes for this type of thing.

I like autocompletes for this type of thing.

In the backend? That would be neat!

Craig has already built a plugin for Select Box Links. It works really neat. I suppose something like that could work for Members as well. Main point just being that its not really possible to do anything except a tag list using usernames from the front-end right now.

How come I’ve never seen this extension? I’ve been through the entire extensions list and never seen it! Must be going blind, too much mas…. erm, I’ll stop there I think lol ;)

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