0

I have a document library I wish to create a custom display form for. I notice that when a person/group field is displayed in the default automatically generated list, the person is not displayed, but a large block of unsightly HTML is displayed.

Why does this occur and how can I fix this?

Below I have The automatically generated HTML within the form.

            <table border="0" cellspacing="0" width="100%">
                <tr>
                    <td width="190px" valign="top" class="ms-formlabel">
                        <H3 class="ms-standardheader">
                            <nobr>Title</nobr>
                        </H3>
                    </td>
                    <td width="400px" valign="top" class="ms-formbody">
                        <xsl:value-of select="@Title"/>
                    </td>
                </tr>
                <tr>
                    <td width="190px" valign="top" class="ms-formlabel">
                        <H3 class="ms-standardheader">
                            <nobr>Responsible for Next Step</nobr>
                        </H3>
                    </td>
                    <td width="400px" valign="top" class="ms-formbody">
                        <xsl:value-of select="@Responsible_x0020_for_x0020_Next_x0020_Step"/>
                    </td>
                </tr>

1 Answer 1

1

By "unsightly HTML" do you perhaps mean something like this?

<nobr><span><a href="/yoursite/_layouts/userdisp.aspx?ID=1">Some User</a><img border="0" height="1" width="3" src="/_layouts/images/blank.gif"/><a href='javascript:;' onclick='IMNImageOnClick(event);return false;' class='ms-imnlink'><img name='imnmark' class='ms-imnImg' title='' border='0' height='12' width='12' src='/_layouts/images/blank.gif' alt='No presence information' sip='[email protected]' id='imn_8,type=sip'/></a></span></nobr>

Well, this is definitely not a bug. Person field are actually lookup fields, and that explains why you get this piece of HTML code (if you look more closely, you'll see that it's an <a> tag).

Simply add the following attribute to the <xsl:value-of> tag:

   <xsl:value-of select="@your-field" disable-output-escaping="yes"/>
2
  • This was exactly what I was looking for! At least that is easily changeable, it just seems like something you would expect to be the default output of a new form as it is the most common display of these fields. But anyways, thanks for the help!
    – cm2
    Commented Jun 26, 2015 at 17:17
  • Actually, it should be the default when you create a new display form in SPD (at least, on my machine/with my SPD, when I create a custom display form, the disable-output-escaping is automatically added to person fields). Glad it helped!
    – MdMazzotti
    Commented Jun 26, 2015 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.