入力タイプの属性が 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>