Search

It should be all covered in the Readme. It seems this one slipped.

Uh Oh.

Running Symphony 2.3.0

Getting this error on submit of a form using Sections Event. (*EDIT - see screenshot)

Here is my form code:

<form class="custom">
        <label>Product Name
          <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="'item'"/>
            <xsl:with-param name="handle" select="'product-title'"/>
            <xsl:with-param name="value" select="product-title"/>
          </xsl:call-template>
        </label><br/>

        <label>Product Price
          <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="'item'"/>
            <xsl:with-param name="handle" select="'product-price'"/>
            <xsl:with-param name="value" select="product-price"/>
          </xsl:call-template>
        </label><br/>

        <label>Product Inventory
          <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="'item'"/>
            <xsl:with-param name="handle" select="'inventory'"/>
            <xsl:with-param name="value" select="inventory"/>
          </xsl:call-template>
        </label><br/>

        <input name="sections[__id]" value="{@id}" type="hidden"/>
        <input type="submit" class="small button" value="Save and Exit"/>
      </form>

Any ideas?

Attachments:
Screen Shot 2013-03-10 at 21.38.45.png

Just for the record - I realise in my code snippet that the submit button is incorrect.

I just tried again with the correct button markup, but the same error message appears.

You should log an issue on GitHub. It seems it's a problem in the core.

Btw, this line:

<input name="sections[__id]" value="{@id}" type="hidden"/>

I think it should probably be:

<input name="sections[item][__id]" value="{@id}" type="hidden"/>

because you're editing an entry in Item section, right?

Githubbed, and duly noted. Will edit when I am back at my laptop :) Thank you :)

^ the code above isn't updating the section as intended, instead it is making a new entry within the section. Any ideas?

I am looking at form:variable and other routes too...

The syntax to edit an entry is this one:

<input name="sections[<<SECTION-HANDLE>>][__edit]" type="hidden" value="<<ENTRY-ID>>">

The HTML from your form looks like it?

^ just tried this syntax too and the entry doesn't get updated. I debugged the {@id} part of the form and it does return the correct entry ID, but nothing is being updated.

:| weird ... Can you post here the resulting HTML from your form?

I'm using the Date and Time field to get a range of dates. Previously, I used <input type="text" name="fields[dates][start][]"/>. Now with Sections Event I need <input type="text" name="sections[listings][dates][start][]"/>. I'm not sure how to do this using sform-controls. Any help?

Also, what does the param interpretation do? If I just manually add this input without going through sform-controls will things get messed up?

@Pat

I'm using the Date and Time field to get a range of dates.

Have a look at example #5 from the Readme. It covers exactly DateTime field. Applied to your use case, this should do it:

<xsl:call-template name="sform:input">
    <xsl:with-param name="section" select="'listings'"/>        
    <xsl:with-param name="handle" select="'dates'"/>
    <xsl:with-param name="suffix" select="'start/ '"/>        
    <xsl:with-param name="attributes">
        <type>date</type>
        <placeholder>Start date</placeholder>
    </xsl:with-param>
</xsl:call-template>

Also, what does the param interpretation do?

Well, the Validation section from the Readme is a must read.

You want to get the error messages from the event, if they exist, and return feedback to the user, right?

As pointed out in Validation section, the template sform:validation-interpret extracts this information from the event and returns it in a consistent way (= easy to manipulate and to render).

Each sform:control will compute this information, but for performance reasons, you can pass it as a parameter. In Example #6, as a best practice I'm computing this data once and send it as a parameter to each control.

Ah, I totally didn't realize that was the same field! Thanks :)

Re: suffix. Do we always need a trailing space, e.g. 'start/ '? I seem to get the same output with 'start/'.

If I understand it correctly, the sform:validation-interpret for each field makes the XML which is then used for sform:validation-render?

Also, looking through the templates, it doesn't look like there are checkbox lists or radio lists for select elements? Maybe I can see how Form Controls does it and adapt it.

Do we always need a trailing space, e.g. 'start/ '? I seem to get the same output with 'start/'.

It should be different output. A trailing space will result in a[] added to element name. Useful for arrays.

If I understand it correctly, the sform:validation-interpret for each field makes the XML which is then used for sform:validation-render?

Yep. You are free to not use the sform:validation-render utility and make render the feedback yourself.

it doesn't look like there are checkbox lists or radio lists for select elements

I didn't encounter a viable use case yet so I didn't create any sform:checkbox-list or whatever.

I still get [] without the space. It seems like the trailing slash accomplishes this?

For selects that allow multiple selections, I prefer to use checkbox lists for usability purposes. If anyone wants to use it, here's a utility for checkbox lists. Just add to sform.select.xsl.

Edit: Updated to accept postback values

<!--
    Name: sform:checkbox-list
    Description: Renders select options as checkboxes
    Returns: HTML <input> elements
    Parameters:

    ***** Identification *****
    * `event` (optional, string): The Event powering the form.
    * `prefix` (optional, string): The prefix that will hold all form data.
    * `section` (optional, string): The section to where data should be sent.
    * `position` (optional, string): Index of this entry in a multiple entries situation. Leave empty if not needed.
    * `handle` (mandatory, string): Handle of the field.
    * `suffix` (optional, string): An xPath like string for more flexibility.

    ***** Validation *****
    * `interpretation` (optional, XML node-set): An XML with the validation of the form
    * `interpretation-el` (optional, XML node-set): An XML with the validation for this field

    ***** Element data *****
    * `value` (optional, string): The value sent when the form is submitted.
    * `label-position` (optional, string): Label can be 'before' or 'after' each checkbox. Default is 'after'.
    * `attributes` (optional, node set): Other attributes for this element.
    * `postback-value` (optional, node set): Value to use after form was posted and page reloaded.
    * `postback-value-enabled` (optional, node set): Switcher to enable the display of postback value.
    * `items` (optional, XPath/XML): Options to automatically build a list of <option> elements
    * `options` (optional, HTML): Actual options to be displayed. Mandatory if $items is not supplied
-->
<xsl:template name="sform:checkbox-list">
    <!-- Identification -->
    <xsl:param name="event" select="$sform:event"/>
    <xsl:param name="prefix" select="$sform:prefix"/>
    <xsl:param name="section" select="$sform:section"/>
    <xsl:param name="position" select="$sform:position"/>
    <xsl:param name="handle"/>
    <xsl:param name="suffix" select="$sform:suffix"/>

    <!-- Validation -->
    <xsl:param name="interpretation">
        <xsl:call-template name="sform:validation-interpret">
            <xsl:with-param name="event" select="$event"/>
            <xsl:with-param name="prefix" select="$prefix"/>
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="position" select="$position"/>
            <xsl:with-param name="fields-sel">
                <xsl:call-template name="sform:validation-tpl-sel">
                    <xsl:with-param name="handle" select="$handle"/>
                    <xsl:with-param name="extMode" select="'update'"/>
                    <xsl:with-param name="suffix" select="$suffix"/>
                </xsl:call-template>
            </xsl:with-param>
        </xsl:call-template>
    </xsl:param>
    <xsl:param name="interpretation-el" select="exsl:node-set($interpretation)/fields/item[ @handle = $handle ]"/>

    <!-- Element data -->
    <xsl:param name="value" select="''"/>
    <xsl:param name="label-position" select="'after'"/>
    <xsl:param name="attributes" select="''"/>
    <xsl:param name="postback-value" select="''"/>
    <xsl:param name="postback-value-enabled" select="true()"/>
    <xsl:param name="items" select="''"/>
    <xsl:param name="options">
        <xsl:for-each select="exsl:node-set($items)/* | exsl:node-set($items)">
            <xsl:if test="text() != ''">
                <option>
                    <xsl:if test="@handle or @id or @link-id or @link-handle or @value">
                        <xsl:attribute name="value">
                            <xsl:value-of select="@handle | @id | @link-id | @link-handle | @value"/>
                        </xsl:attribute>
                    </xsl:if>

                    <xsl:value-of select="text()"/>
                </option>
            </xsl:if>
        </xsl:for-each>
    </xsl:param>

    <xsl:variable name="pb-value">
        <xsl:choose>
            <xsl:when test="$postback-value != ''">
                <xsl:value-of select="$postback-value"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="sform:postback-value">
                    <xsl:with-param name="event" select="$event"/>
                    <xsl:with-param name="section" select="$section"/>
                    <xsl:with-param name="position" select="$position"/>
                    <xsl:with-param name="handle" select="$handle"/>
                    <xsl:with-param name="suffix" select="$suffix"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    <xsl:for-each select="exsl:node-set($items)/* | exsl:node-set($items)">
        <label>
            <xsl:if test="$label-position = 'before'">
                    <xsl:value-of select="."/>
            </xsl:if>
            <xsl:call-template name="sform:checkbox">
                <xsl:with-param name="event" select="$event"/>
                <xsl:with-param name="handle" select="$handle"/>
                <xsl:with-param name="section" select="$section"/>
                <xsl:with-param name="suffix" select="'/'"/>

                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="interpretation-el" select="$interpretation-el"/>

                <xsl:with-param name="value">
                    <xsl:choose>
                        <xsl:when test="@value"><xsl:value-of select="@value"/></xsl:when>
                        <xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
                    </xsl:choose>
                </xsl:with-param>
                <xsl:with-param name="postback-value" select="$postback-value"/>
                <xsl:with-param name="postback-value-enabled" select="$postback-value-enabled"/>
                <xsl:with-param name="options" select="$options"/>
                <xsl:with-param name="attributes">
                    <xsl:if test="@selected"><checked>checked</checked></xsl:if>
                    <xsl:choose>
                        <xsl:when test="contains($pb-value, .)">
                            <checked>checked</checked>
                        </xsl:when>
                    </xsl:choose>
                    <id></id>
                </xsl:with-param>
            </xsl:call-template>
            <xsl:if test="$label-position = 'after'">
                    <xsl:value-of select="."/>
            </xsl:if>
        </label>
    </xsl:for-each>
</xsl:template>

I'm running into some issues with my form.

  1. I cannot get error/success messages to show up. I have validation-render in my form.
  2. All whitespace in the form has been killed. How could I bring it back? Edit: whitespace has returned
  3. This redirect doesn't give me the entry id <input type="hidden" name="sections[__redirect]" value="/done/%listings[system:id]%/"/>.

Here's my code:

<form method="post">

    <fieldset>
        <legend>Add new listing</legend>

        <!-- Interpret the values from event. It can be customized. See the implementation -->
        <xsl:variable name="interpretation">
            <xsl:call-template name="sform:validation-interpret"/>
        </xsl:variable>

        <!-- Render this interpretation as pretty HTML. It can be customized. See the implementation -->
        <xsl:call-template name="sform:validation-render">
            <xsl:with-param name="interpretation" select="$interpretation"/>
        </xsl:call-template>

        <!-- Title -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'title'"/>
            <xsl:with-param name="value" select="'Title'"/>
            <xsl:with-param name="attributes">
                <class>required</class>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'title'"/>
        </xsl:call-template>

        <!-- Description -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'description'"/>
            <xsl:with-param name="value" select="'Description'"/>
        </xsl:call-template>
        <xsl:call-template name="sform:textarea">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'description'"/>
        </xsl:call-template>

        <!-- Room Type -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'room-type'"/>
            <xsl:with-param name="value" select="'Room type'"/>
            <xsl:with-param name="attributes">
                <class>required</class>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="sform:select">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'room-type'"/>
            <xsl:with-param name="items" select="listing-fields/room-type/options/*"/>
            <xsl:with-param name="value" select="'Room'"/>
        </xsl:call-template>

        <!-- Dates -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'dates'"/>
            <xsl:with-param name="suffix" select="'start/ '"/>              
            <xsl:with-param name="value" select="'Dates'"/>
            <xsl:with-param name="attributes">
                <class>required</class>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'dates'"/>
            <xsl:with-param name="suffix" select="'start/ '"/>              
            <xsl:with-param name="attributes">
                    <type>date</type>
                    <placeholder><xsl:value-of select="'yyyy-mm-dd'"/></placeholder>
            </xsl:with-param>
        </xsl:call-template>
        to
        <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'dates'"/>
            <xsl:with-param name="suffix" select="'end/ '"/>                
            <xsl:with-param name="attributes">
                    <type>date</type>
                    <placeholder><xsl:value-of select="'yyyy-mm-dd'"/></placeholder>
            </xsl:with-param>
        </xsl:call-template>

        <!-- Address -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'address'"/>
            <xsl:with-param name="suffix" select="'street'"/>               
            <xsl:with-param name="value" select="'Address'"/>
            <xsl:with-param name="attributes">
                <class>required</class>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'address'"/>
            <xsl:with-param name="suffix" select="'street'"/>               
            <xsl:with-param name="attributes">
                <placeholder>Street address</placeholder>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="sform:input">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'address'"/>
            <xsl:with-param name="suffix" select="'zip-code'"/>             
            <xsl:with-param name="attributes">
                <placeholder>Zip code</placeholder>
            </xsl:with-param>
        </xsl:call-template>

        <!-- Borough -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'borough'"/>
            <xsl:with-param name="value" select="'Borough'"/>
            <xsl:with-param name="attributes">
                <class>required</class>
            </xsl:with-param>
        </xsl:call-template>
        <xsl:call-template name="sform:select">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'borough'"/>
            <xsl:with-param name="items" select="listing-fields/borough/options/*"/>
            <xsl:with-param name="value" select="'Manhattan'"/>
        </xsl:call-template>

        <!-- Price -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'price'"/>
            <xsl:with-param name="value" select="'Monthly price'"/>
            <xsl:with-param name="attributes">
                <class>required</class>
            </xsl:with-param>
        </xsl:call-template>
        <div class="input-prepend">
            <span class="add-on">$</span>
            <xsl:call-template name="sform:input">
                <xsl:with-param name="section" select="$section"/>
                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="handle" select="'price'"/>
            </xsl:call-template>
        </div>

        <!-- Utilities -->
        <div class="checkbox-list">
            <label>Utilities included</label>
            <xsl:call-template name="sform:checkbox-list">
                <xsl:with-param name="section" select="$section"/>              
                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="handle" select="'utilities'"/>
                <xsl:with-param name="items" select="listing-fields/utilities/options/*"/>
            </xsl:call-template>
        </div>

        <!-- Gender -->
        <div class="checkbox-list">
            <label class="required">Gender(s) wanted</label>
            <xsl:call-template name="sform:checkbox-list">
                <xsl:with-param name="section" select="$section"/>              
                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="handle" select="'gender'"/>
                <xsl:with-param name="items" select="listing-fields/gender/options/*"/>
            </xsl:call-template>
        </div>

        <!-- Climate control -->
        <div class="checkbox-list">
            <label>Climate control</label>
            <xsl:call-template name="sform:checkbox-list">
                <xsl:with-param name="section" select="$section"/>              
                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="handle" select="'climate-control'"/>
                <xsl:with-param name="items" select="listing-fields/climate-control/options/*"/>
            </xsl:call-template>
        </div>

        <!-- Bathroom -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'bathroom'"/>
            <xsl:with-param name="value" select="'Bathroom'"/>
        </xsl:call-template>
        <xsl:call-template name="sform:select">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'bathroom'"/>
            <xsl:with-param name="items" select="listing-fields/bathroom/options/*"/>
            <xsl:with-param name="value" select="'Shared'"/>
        </xsl:call-template>

        <!-- Closets -->
        <xsl:call-template name="sform:label">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'closets'"/>
            <xsl:with-param name="value" select="'Closets'"/>
        </xsl:call-template>
        <xsl:call-template name="sform:select">
            <xsl:with-param name="section" select="$section"/>
            <xsl:with-param name="interpretation" select="$interpretation"/>
            <xsl:with-param name="handle" select="'closets'"/>
            <xsl:with-param name="items" select="listing-fields/closets/options/*"/>
            <xsl:with-param name="value" select="'0'"/>
        </xsl:call-template>

        <!-- Laundry -->
        <div class="checkbox-list">
            <label>Laundry</label>
            <xsl:call-template name="sform:checkbox-list">
                <xsl:with-param name="section" select="$section"/>
                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="handle" select="'laundry'"/>
                <xsl:with-param name="items" select="listing-fields/laundry/options/*"/>
            </xsl:call-template>
        </div>

        <!-- Other features -->
        <div class="checkbox-list">
            <label>Other features</label>
            <xsl:call-template name="sform:checkbox-list">
                <xsl:with-param name="section" select="$section"/>
                <xsl:with-param name="interpretation" select="$interpretation"/>
                <xsl:with-param name="handle" select="'other-features'"/>
                <xsl:with-param name="items" select="listing-fields/other-features/options/*"/>
            </xsl:call-template>
        </div>


        <input name="sections[{$section}][user]" type="hidden" value="{current-user/entry/@id}"/>
        <input type="hidden" name="sections[__redirecTt]" value="/done/%listings[system:id]%/"/>

        <button name="action[sections]" type="submit" class="btn btn-primary">Submit</button>
    </fieldset>

</form>

Re: #1. It seems that when you create $interpretation, <xsl:call-template name="sform:validation-interpret"/> actually needs to be passed a $section. This should be made clear in the readme, as the example didn't pass section param. Also, it would be nice if the readme explained the structure of an intepretation for anyone who may want to customize the validation output.

Also, Sections event does not seem capable of accepting file uploads. I am able to upload files through regular events, but when using Sections event, I get FIELDNAME is a required field as if I did not select an image.

Also, it would be nice if the readme explained the structure of an intepretation for anyone who may want to customize the validation output.

Validation in Readme explaing the structure of interpretation.

Sections event does not seem capable of accepting file uploads.

Ooops! I admin I never tried an upload field :)

actually needs to be passed a $section

Good spot! I'll update the Readme as well.

This redirect doesn't give me the entry id <input type="hidden" name="sections[__redirect]" value="/done/%listings[system:id]%/"/>.

Very odd. I'll look into it.

P.S. Perhaps you have a glitch in your form? (from above code you have pasted):

<input type="hidden" name="sections[__redirecTt]" value="/done/%listings[system:id]%/"/>

Ah I totally misunderstood that part of the readme. Thanks!

I can confirm the redirect does not work (without the typo). It gives me the URL /done/%listings[system:id]%/ not /done/33/

Ah I totally misunderstood that part of the readme.

Glad it's OK now.

I updated Sections Event to 1.3. It should fix the __redirect issue.

Please let me know if it works. Thanks!

Redirect works! Should this update also fix the file upload issue?

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