我想在 xslt 中检查输入类型的属性是单选还是多选,如何获取属性 mselect 并测试它的表达式,如果我获得了属性 mselect,那么我将附加新的 css 类,否则显示默认布局我的代码如下。
我有一个由管理员管理的字段,如果管理员将该字段设置为单选,那么它会显示简单的选择框,或者如果管理员将其设置为多选,那么它会显示多选输入,但是在两个选项上应用相同的 html 结构,但我希望它不同的。
<!-- select HTML code -->
<div class="controls category">
<label>
<select style="width: 250px;" class="cattest" id="field_category" name="field_category">
<option value="">Select Category</option>
<option value="36" disabled="disabled">- East Perth Cemetery</option>
<option value="37">-- Genealogical (people)</option>
<option value="38">-- Architectural (monuments)</option>
</select>
<span class="hide message-lightbulb" id="field_category-message">
<i class="icon-lightbulb"></i>
</span>
</label>
</div>
<!-- mselect HTML code -->
<div class="controls category">
<label>
<select style="width: 250px; height: 100px" class="cattest" id="field_category" multiple="multiple" name="field_category[]">
<option value="36" disabled="disabled">- East Perth Cemetery</option>
<option value="37">-- Genealogical (people)</option>
<option value="38">-- Architectural (monuments)</option>
</select>
<span class="hide message-lightbulb" id="field_category-message">
<i class="icon-lightbulb"></i>
</span>
</label>
</div>
我想要它:
<!-- select HTML code -->
<div class="controls category">
<label>
<select style="width: 250px;" class="cattest" id="field_category" name="field_category">
<option value="">Select Category</option>
<option value="36" disabled="disabled">- East Perth Cemetery</option>
<option value="37">-- Genealogical (people)</option>
<option value="38">-- Architectural (monuments)</option>
</select>
<span class="hide message-lightbulb" id="field_category-message">
<i class="icon-lightbulb"></i>
</span>
</label>
</div>
<!-- mselect HTML code -->
<div class="controls category">
<select style="width: 250px; height: 100px" class="cattest" id="field_category" multiple="multiple" name="field_category[]">
<option value="36" disabled="disabled">- East Perth Cemetery</option>
<option value="37">-- Genealogical (people)</option>
<option value="38">-- Architectural (monuments)</option>
</select>
<span class="hide message-lightbulb" id="field_category-message">
<i class="icon-lightbulb"></i>
</span>
</div>
它的xslt代码是:
<xsl:if test="count( /search/fields/* ) > 3">
<div id="SPExtSearch">
<xsl:for-each select="fields/*">
<xsl:if test="position() > 3">
<xsl:variable name="i" select="position()"/>
<xsl:variable name="fieldId" select="name(.)" />
<xsl:variable name="description" select="description" />
<xsl:variable name="fldalias" select="substring(name(.),1,9)"/>
<xsl:variable name="ftype" select="@type" />
<xsl:variable name="fstyle" select="width" />
<xsl:variable name="title">
<!-- <xsl:value-of select="@id" />-->
<xsl:value-of select="php:function('SobiPro::Csm', @id)" />
</xsl:variable>
<xsl:if test="$title = 1">
<div class="control-group {$fieldId} {$fldalias}">
<label class="control-label payment-box" for="{name(.)}" >
<xsl:value-of select="label"/>
</label>
<div class="controls {$ftype}">
<label>
<xsl:if test="string-length( @suffix )">
<xsl:attribute name="class">input-append</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="data/@escaped">
<xsl:value-of select="data" disable-output-escaping="yes" />
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="data/*" />
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="string-length( @suffix )">
<span class="add-on">
<xsl:value-of select="@suffix" />
</span>
</xsl:when>
<xsl:otherwise>
<span id="{$fieldId}-message" class="hide message-lightbulb">
<i class="icon-lightbulb" />
</span>
</xsl:otherwise>
</xsl:choose>
</label>
</div>
</div>
</xsl:if>
</xsl:if>
</xsl:for-each>
</div>
<div class="clearfix" />
</xsl:if>