Update 31-03-2009
Folks, another update.. it’s fixed!! Get the hotfix for SharePoint Designer here KB960311 and make sure that your SharePoint environment is patched with the infrastructure updates.
Update 09-07-2007
Folks, the solution given below does not work! Also there is no fix for it yet, please look in the following forum http://forums.microsoft.com/TechNet/showpost.aspx?postid=1826359&siteid=17 for more details. I am very sorry if you found this blogpost via Google hoping you get an answer.. :(
Well until recently I did not know how to fix this (and I wasn't the only one if you check out this forum post on TechNet and these comments on a post of Jan Tielens's blog) until I received an alert from the forum that there was a new post with the solution. And here is the solution :
This is the code you need for attachments to work:
<SharePoint:AttachmentUpload ControlMode="Edit" runat="server"
ID="fileupload{$Pos}">
</SharePoint:AttachmentUpload>
<SharePoint:AttachmentsField ControlMode="Edit"
FieldName="Attachments" runat="server" Visible="true">
</SharePoint:AttachmentsField>
This will display the input field and the buttons as well as what you're trying to upload.
1) First make sure your field and test case works (Edit form) without the attachments.
2) What I did was put the attachments in a separate xsl template:
<xsl:template name="attachments">
<xsl:param name="Pos" />
<tr><td>
<SharePoint:AttachmentUpload ControlMode="Edit" runat="server"
ID="fileupload{$Pos}">
</SharePoint:AttachmentUpload>
<SharePoint:AttachmentsField ControlMode="Edit"
FieldName="Attachments" runat="server" Visible="true">
</SharePoint:AttachmentsField>
</td></tr>
</xsl:template>
3) and then I changed the dvt_1 template:
<xsl:template name="dvt_1">
<xsl:variable name="dvt_StyleName">ListForm</xsl:variable>
<xsl:variable name="Rows"
select="/dsQueryResponse/Rows/Row"/>
<table border="0" width="100%" id="part1{$noop}">
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows"/>
</xsl:call-template>
</table>
<table border="0" width="100%">
<xsl:call-template name="attachments">
<xsl:with-param name="Pos" select="concat('_',
position())" />
</xsl:call-template>
</table>
</xsl:template>
A few things that are important to remember:
The JavaScript in SharePoint will look for the object with id part1 in the final HTML and hide the object (display:hidden css style) and the object id partAttachment and display that object. The partAttachment object (span) is automatically generated when you introduce the SharePoint:AttachmentUpload code. The part1 id however, you need to introduce yourself.
Now, if you don't want that anything hides, just put in an empty element somewhere with the id part1{$noop}, otherwise, just use my example for the dvt_1 template (it's neater).
The $noop is to fool SharePoint Designer since it will introduce {generate-id()} after the id if you don't specify anything there (to guarantee unique identifiers or something, I don't know) and thus it would fail the javascript since it can't find id=part1, but there will be a part1KLV532.
You can specify the noop parameter to be empty in the beginning of your xsl stylesheet:
<xsl:param name=noop></xsl:param>
Evi
So thanks Evi! :)