I'm using a dropdownlist multiple, publishing keys data type and I'm trying to create a select whose options have their value attribute set to the ID of the dropdownlist item and their text set to the text of the dropdownlist item. I'm currently trying to do the following:
This is throwing an "error parsing XSLT file" error though when the page is rendered. The line causing that error is the <xsl:value-of select="umbraco.library:GetPreValueAsString(number(current()))"/> but when I run a stack trace, no errors are returned. If I try substituting one of the dropdownlist item's id's statically in place of number(current()) it returns the text of that item so I tried just using <xsl:value-of select="number(current())"/> but that returns NaN because for some reason current() is returning the text instead of the id's. Has anyone else experienced this and know how to fix it?
I think that your are on the right track, I have just find a solution, where I get the id of the prevalue in the value attribute and the text value in the dropdown list.
Just make sure that your Dropdown multiple datat type are using Property editor called Dropdown list multiple, publish keys, then you should be able to get the key and the text foreach predefine value. I have made a screenshot to make it easier to understand what I mean.
GetPreValueAsString not working
I'm using a dropdownlist multiple, publishing keys data type and I'm trying to create a select whose options have their value attribute set to the ID of the dropdownlist item and their text set to the text of the dropdownlist item. I'm currently trying to do the following:
<xsl:if test="string-length($currentPage/prostateCancerSpecialties) > 0">
<xsl:variable name="specialties" select="umbraco.library:Split($currentPage/prostateCancerSpecialties,',')" />
<xsl:for-each select="$specialties/value">
<option>
<xsl:attribute name="value">
<xsl:value-of select="umbraco.library:GetPreValueAsString(number(current()))"/>
</xsl:attribute>
<xsl:value-of select="current()"/>
</option>
</xsl:for-each>
</xsl:if>
This is throwing an "error parsing XSLT file" error though when the page is rendered. The line causing that error is the <xsl:value-of select="umbraco.library:GetPreValueAsString(number(current()))"/> but when I run a stack trace, no errors are returned. If I try substituting one of the dropdownlist item's id's statically in place of number(current()) it returns the text of that item so I tried just using <xsl:value-of select="number(current())"/> but that returns NaN because for some reason current() is returning the text instead of the id's. Has anyone else experienced this and know how to fix it?
Hi Anthony,
I think that your are on the right track, I have just find a solution, where I get the id of the prevalue in the value attribute and the text value in the dropdown list.
Just make sure that your Dropdown multiple datat type are using Property editor called Dropdown list multiple, publish keys, then you should be able to get the key and the text foreach predefine value. I have made a screenshot to make it easier to understand what I mean.
Hope this helps,
/Dennis
is working on a reply...