Search

Please continue this bug fix in the ETF thread, or a new thread, as this one is for Form Controls.

The $ isn't being replaced with the input text value:

<xsl:call-template name="form:label">
    <xsl:with-param name="for" select="'name'"/>
    <xsl:with-param name="text" select="'Name'"/>
    <xsl:with-param name="template">
        <th> $ <span class="required">*</span> </th>
    </xsl:with-param>
    <xsl:with-param name="child">
      <td>
        <xsl:call-template name="form:input">
            <xsl:with-param name="handle" select="'name'"/>
        </xsl:call-template>
      </td>
    </xsl:with-param>
</xsl:call-template>

Any ideas? First time using the template parameter.

You may have discovered a bug. The actual replacement looks for a node whose text is exactly $, therefore a preceding space might trip it up. This will work:

<th><span>$</span> <span class="required">*</span></th>

I'll need to look into the replacement technique, and maybe that example in the README is misleading. If you're interested, it uses the ninja technique:

<!--
Name: form:replace-template, matches element nodes
Description: traverse a block of XML and replace placeholder with text string
Returns: XML
-->
<xsl:template match="*" mode="form:replace-template">
    <xsl:param name="replacement"/>
    <xsl:element name="{name()}">
        <xsl:apply-templates select="* | @* | text()" mode="form:replace-template">
            <xsl:with-param name="replacement" select="$replacement"/>
        </xsl:apply-templates>
    </xsl:element>
</xsl:template>

<!--
Name: form:replace-template, matches attribute node
Description: traverse a block of XML and replace placeholder with text string
Returns: XML
-->
<xsl:template match="@*" mode="form:replace-template">
    <xsl:param name="replacement"/>
    <xsl:attribute name="{name(.)}">
        <xsl:value-of select="."/>
    </xsl:attribute>
</xsl:template>

<!--
Name: form:replace-template, matches text nodes
Description: traverse a block of XML and replace placeholder with text string
Returns: XML
-->
<xsl:template match="text()" mode="form:replace-template">
    <xsl:param name="replacement"/>
    <xsl:choose>
        <xsl:when test="string(.)='$'">
            <xsl:value-of select="normalize-space($replacement)"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:value-of select="string(.)"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

The actual replacement looks for a node whose text is exactly $, therefore a preceding space might trip it up.

I was looking at the relevant templates last night but could not figure out the problem (in my defense, it was getting late!). The documentation is what misled me. It might be worthwhile to utilize either contains() or normalize-space() to make it a little forgiving.

Thank you!

XSLTProcessor::importStylesheet(): xsl:attribute-set : use-attribute-sets recursion detected

am getting this error while including the form controls utility in the master.xsl

am having a radio button in a form which is placed in the master.xsl while using the form control am getting this error

any help on this ?

any help on this ?

Not without seeing your code!

<select name="fields[civilite]">
<option value="Mr">Mr</option>
<option value="Mme">Mme</option>
<option value="Mlle">Mlle</option>
</select>

for this am using form controls

 <xsl:call-template name="form:label">
  <xsl:with-param name="text" select="'Mr'"/>
  <xsl:with-param name="child">
  <xsl:call-template name="form:radio">
   <xsl:with-param name="handle" select="'civilite'"/>
  <xsl:with-param name="value" select="'Mr'"/>
   </xsl:call-template>
    </xsl:with-param>
   <xsl:with-param name="child-position" select="'before'"/>
 </xsl:call-template>

for every option

and included

<?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">

and this included this too

<xsl:include href="../utilities/form-controls.xsl"/>
<xsl:variable name="form:event" select="/data/events/become-member"/>

in master.xsl

and am getting this error

 XSLTProcessor::importStylesheet(): xsl:attribute-set : use-attribute-sets recursion detected

Hmm odd, I am unable to recreate this. If I use the above code on a new page it all works fine and the radio button is created.

yeah for me too it works in the pages, but not in the master.xsl

any help?

I still cannot replicate this. If I move the code into my master.xsl it will works. My basic master template:

<?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">

<xsl:include href="form-controls.xsl"/>
<xsl:variable name="form:event" select="/data/events/become-member"/>

<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" />

<xsl:template match="/">

    <html>
        <body>

            <!-- create label/input, appears on every page -->
            <xsl:call-template name="form:label">
                <xsl:with-param name="text" select="'Mr'"/>
                <xsl:with-param name="child">
                    <xsl:call-template name="form:radio">
                        <xsl:with-param name="handle" select="'civilite'"/>
                        <xsl:with-param name="value" select="'Mr'"/>
                    </xsl:call-template>
                </xsl:with-param>
                <xsl:with-param name="child-position" select="'before'"/>
            </xsl:call-template>

            <!-- apply templates for page -->
            <xsl:apply-templates select="data"/>

        </body>
    </html>

</xsl:template>

</xsl:stylesheet>

And then I create a page:

    <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:include href="../utilities/master.xsl"/>

<xsl:template match="data">
    <h1>My Page</h1>
</xsl:template>

</xsl:stylesheet>

This creates the expected output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
    <body> 
        <label class=""><input name="fields[civilite]" id="fields-civilite" title="" class="" type="radio" value="Mr" />Mr </label> 
        <h1>My Page</h1> 
    </body> 
</html>

If you still can't solve this, then please start a new thread and paste up your full XML and XSLT for all relevant files (you might find http://pastie.org easier for pasting code).

<xsl:call-template name="form:label">
    <xsl:with-param name="text" select="'Mlle'"/>
    <xsl:with-param name="child">
        <xsl:call-template name="form:radio">
            <xsl:with-param name="handle" select="'civilite'"/>
            <xsl:with-param name="value" select="'Mlle'"/>

        </xsl:call-template>

    </xsl:with-param>
    <xsl:with-param name="child-position" select="'before'"/>
    <xsl:with-param name="allow-multiple" select="'yes'"/>
</xsl:call-template>

xlst Code for radio button

<select name="fields[0][civilite]">
 <option value="Mr">Mr</option>
<option value="Mlle">Mlle</option>
</select>

i want to change the radio form controls to accept array of values that is

<input name="fields[0][civilite]" type="radio"/>

how to achieve this name in form controls (ie []- adding this in the fields name)

@nick

I setup a form, filled some test data and sent it. Everything went fine, data was sent, entry created and page with form showed up again BUT without default values.

On simple page load, form fills default values.
On page load after form submit, default values are not filled.

Any ideas why this behavior?

Edit: After reading Form Controls threads, you stated here

will probably not work with maintaining postback values and validation.

Why is that? I'm in some trouble with a multilingual field which uses:

fields[__handle__][value-__langCode__]:
fields[nume][value-ro]
fields[nume][value-en]
...

I need to persist values after checking but can't seem to do so. XSLT:

<xsl:call-template name="form:input">
    <xsl:with-param name="handle" select="'value-ro'"/>
    <xsl:with-param name="section" select="'fields[nume]'" />
</xsl:call-template>

Any ideas how could I postback values after validation?

Most likely because the multilingual field uses non-standard XML in Tge event output. Form Controls is quite strict about the output, and looks for known patterns, which works for the core fields. As with the Members Password field which shares similar problems, you're probably best building this particular form widget manually.

Ideally Form Controls would be rewritten to account for these more complex fields. If you fancy the challenge then please be my guest!

Ahh, thanks for making it clear.

Ideally Form Controls would be rewritten to account for these more complex fields. If you fancy the challenge then please be my guest!

One day, when my XSL is a bit more than average...

Form Controls updated to version 1.6 on 1st of December 2011

@nick

Ideally Form Controls would be rewritten to account for these more complex fields. If you fancy the challenge then please be my guest!

It's time to make it happen. I looked through the code and I realised it won't be done in 30 minutes :)

Any preliminary ideas & suggestions? Anything I should be aware of?

form:textarea which rendering as <textarea /> element seem to mess up with form in HTML, how do I solve it? By enforce the content type in XHTML?

What does your call-template look like?

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