Search

I follow nick's example in Git

    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:exsl="http://exslt.org/common"
    xmlns:form="http://nick-dunn.co.uk/xslt/form-controls"
    extension-element-prefixes="exsl form">

<!-- Import form-controls.xsl -->
<xsl:import href="../utilities/form-controls.xsl"/>

<!-- Define a global variable pointing to your Event -->
<xsl:variable name="form:event" select="/data/events/save-blog-post"/>

<xsl:template match="data">

    <form action="" method="post">

        <fieldset>
            <legend>Create new post</legend>

            <xsl:call-template name="form:validation-summary"/>

            <label>
                Post title<br/>
                <xsl:call-template name="form:input">
                    <xsl:with-param name="handle" select="'title'"/>
                </xsl:call-template>
            </label>

            <label>
                Post contents<br/>
                <xsl:call-template name="form:textarea">
                    <xsl:with-param name="handle" select="'content'"/>
                </xsl:call-template>
            </label>

        </fieldset>

    </form>

</xsl:template>

</xsl:stylesheet>

I forgot to ask, what do you mean by "mess up"? Can you attach a screenshot…

The textarea when render in HTML will contain other part of the element to display. http://postimage.org/image/fkaqh6mcx/

Hmm, I'm not sure... never encountered that before. What happens if you disable any CSS or JavaScript?

Oh, I forgot this was need, and it output correctly! Thanks lewis, you got me struck an idea.

<xsl:output method="xml"
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
  omit-xml-declaration="yes"
  encoding="UTF-8"
  indent="yes" />

Ahh, cool, that makes sense. Glad you figured it out!

Hi Nick,

First thanks a lot for this great utility that's going to save me a lot of time. I'm new to symphony, and there's something I try to achieve but can't find a way. I would like to build a select field with the entry id as value for the option element.

My datasource looks like this (I'm using union datasource : )

<my-union-datasource>
....
 <section id="73" handle="my-section">my-section</section>
....
 <entry id="957" section-handle="my-section">
    <name  handle="item1">item1</name>
  </entry>
  <entry id="958" section-handle="my-section">
    <name  handle="item2">item2</name>
  </entry>
  <entry id="959" section-handle="my-section">
    <name  handle="item3">item3</name>
  </entry>
…..
</my-union-datasource>

My xslt sheet :

<xsl:call-template name="form:select">
  <xsl:with-param name="handle" select="'my-field'"/>
  <xsl:with-param name="options">
    <option value="">Choose from the list:</option>
    <xsl:copy-of select="/data/my-union-datasource/entry[@section-handle='my-section']/name"/>
  </xsl:with-param>
</xsl:call-template>

The result

<select name="fields[my-field]" id="fields-my field" title="" class="">
  <option value="" selected="selected">Choose from the list:</option>
  <option value="item2">item1</option>
  <option value="item2">item2</option>
  <option value="item3">item3</option>
</select>

Now I need the option value parameter to be the 'id' of the entry element instead of the handle of the name element. Is there a way to customize the value with Form Controls ??

Thanks

Try just passing in

/data/my-union-datasource/entry[@section-handle='my-section']

To the options. I don't 'get' the FormControls too well, but from what I see of the source, this may work.

I think designermonkeys way will work. The docs say

Each node passed to this (options) parameter will be converted to an HTML option element. If the node has an attribute of the following names: handle, id, link-id, link-handle or value; these will be used as the value attribute of the option element.

Or you could create the options by hand, like

<xsl:with-param name="options">
    <option value="">Choose from the list:</option>
    <xsl:for-each select="/data/my-union-datasource/entry[@section-handle='my-section']">
        <option value="{@id}">
            <xsl:value-of select="name"/>
        </option>
    </xsl:for-each>
</xsl:with-param>

@designmonkey(#48) This solution did indeed set the value params with the id, but then the text of the option tag disappeared.

@klaftertief(#49) This worked !!!! Everything's good now

Thanks a lot guys for the quick answer.

It's running on symphony 2.3 version?

Thanks.

No compatibility issues I'm aware of.

Is it possible to set a height (number of rows) for a form:select w/ multiple selections enabled? I just did a quick review of the XSLT and it didn't look like size is a parameter.

I know this is an old thread and this question has more than likely been answered already, but I'm going to ask anyways cos my mind is mush!

Is it possible with Section Schemas and Form Controls to construct a form with the potential to submit multiple entries? or is this where EventEx kicks in?

I have the form working with one entry in Section Schemas and Form Controls but struggling to see how an array of entries can be built using the same markup?

Have you considered using Sections Event?

I'd considered it, but I have a lot of existing code I'd need to change.. so trying to avoid it really... have you used sections event successfull then?

Sections Event has great form control templates that work with Section Schemas, plus multiple entries and linked entries work out of the box.

Ok cool,

Thanks Pat. Will have to give it a try now.. based on your recommendation :)

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