Stump the Panel: SharePoint Q&A

Immediate solutions for common SharePoint questions
It is currently Fri May 24, 2013 6:41 am

All times are UTC - 5 hours [ DST ]


Forum rules


What you are viewing is an archive of Stump the Panel. It remains for reference purposes. Please post all new questions on NothingButSharePoint.com
https://www.nothingbutsharepoint.com/sites/eusp/Forum



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Add fields to Registration form - Employee Training Template
PostPosted: Fri Sep 17, 2010 11:36 am 
Offline

Joined: Fri Sep 17, 2010 10:59 am
Posts: 12
Hello,

We are using SharePoint (I believe it's 2007) at my company, and my department is using the Employee Training Template for training registration. We like the functionality it contains, but there is one shortcoming that we've come across that we need to fix in order to be able to use it.

Using the built-in functionality, I can create a class on the calendar and register for it. But we need to capture some information when users register (department, phone number, etc. -- just a couple of text fields). So I need to add a couple of fields to the Register.aspx page. I want those fields to be required, so that the user cannot click OK until there is data in those fields.

I have added columns for that data in the library, but of course the fields do not appear on the Register.aspx page. I need to manually add them somehow, and I know I need to get into the code of the page to do it. I know a little about it, so I am comfortable enough in that environment, but I have no idea where to start to do this.

Has anybody dealt with this, and can you point me in the right direction?

Thanks!


Top
 Profile  
 
 Post subject: Re: Add fields to Registration form - Employee Training Template
PostPosted: Fri Sep 17, 2010 11:48 am 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
The page has to be opened in Sharepoint Designer and the fields added into the code. I've done extensive work with this template. You'd add something like this:
Code:
<tr style="display: none">
                  <td width="190px" valign="top" class="ms-formlabel">
                     <H3 class="ms-standardheader">
                        <nobr>Course ID<span class="ms-formvalidation"> *</span>
                        </nobr>
                     </H3>
                  </td>
                  <td width="400px" valign="top" class="ms-formbody">
                     <asp:TextBox runat="server" value="{$CourseID}" id="ff1{$Pos}" text="{@Course_x0020_ID}" __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Course_x0020_ID')}" />
                     <SharePoint:FieldDescription runat="server" id="ff1description{$Pos}" FieldName="Course_x0020_ID" ControlMode="New"/>
                  </td>
               </tr>


making sure to set the proper field names and columns and to not reuse any ff# values.

Instead of monkeying with the code, what I did was to create additional people and group columns in my registration list. You can set the display for these columns to phone number and department that get populated from the Active Directory import of your user profiles. Then in the registration workflow, I just added a step that updates these fields to the created by user.


Top
 Profile  
 
 Post subject: Re: Add fields to Registration form - Employee Training Template
PostPosted: Fri Sep 17, 2010 11:51 am 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
Also, I documented a lot of information in my project of updating this template to something usable. You can check pirateeric.wordpress.com for ideas. The content was migrated from my old blog, so some of the links may be dead. If you have any specific questions, feel free to ping me.


Top
 Profile  
 
 Post subject: Re: Add fields to Registration form - Employee Training Template
PostPosted: Fri Sep 17, 2010 11:54 am 
Offline

Joined: Fri Sep 17, 2010 10:59 am
Posts: 12
Thanks for your help, Eric. I am going to take a look at that stuff now.

I tried using the info from AD already, but the information is out of date and not reliable, hence the need to capture at registration. So I think I am going to have to work in the code, unfortunately.


Top
 Profile  
 
 Post subject: Re: Add fields to Registration form - Employee Training Template
PostPosted: Thu Nov 04, 2010 11:37 am 
Offline
User avatar

Joined: Mon Jan 04, 2010 1:15 am
Posts: 1839
Location: North Carolina
I'm making more revisions to my template so the information is pretty fresh in my mind right now. I'll walk you through it.

Add the additional columns you require in the Registrations list.

In the Registrations list settings page, mouse over these new fields and note the field name in the bottom bar of the browser. If the full name doesn't appear, click on the link for the field and jot down the internal field name from the query string. If you see escaped markup like this, replace the %5F with an underscore.
Code:
Field=Employee%5Fx0020%5FPhone


Open Sharepoint Designer, expand the Lists, expand Registrations, and open the Register.aspx page. Navigate down the page until you get to the <xsl:template name="dvt_1.rowedit"> section.

Find this bit of code.
Code:
<tr style="display: none">
  <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">
   <asp:TextBox runat="server" value="Form loaded {$Today}" id="ff2{$Pos}" text="{@Title}" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" />
   <SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="Title" ControlMode="New"/>
   </td>
</tr>

Copy this section of code and paste in as many times as columns as you created. Delete style="display: none" from the TR. Replase the ASP text box code with:
Code:
<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="New" FieldName="Title" __designer:bind="{ddwrt:DataBind('i',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}"/>

Now replace each instance of ff2 with a unique number. I typically start at 9000 so I know that I won't run into any issues with collisions. For each additional column, add 1 to the value you started with. Replace the FieldName values with the display name of the column and replace @Title with @TheColumnName you jotted down above. If you can't recall these, refresh the datasource on the page and the fields should show up in the DataFields section of the web part.

Save the changes and try to register for a class. It might be beneficial to try this on 1 additional column at first to make sure it's all functioning properly.

Also, if you want the field to be mandatory, use this code.
Code:
<nobr>Field Display Name<span class="ms-formvalidation"> *</span></nobr>


Top
 Profile  
 
 Post subject: Re: Add fields to Registration form - Employee Training Template
PostPosted: Thu Nov 04, 2010 12:01 pm 
Offline

Joined: Fri Sep 17, 2010 10:59 am
Posts: 12
Wow, it worked like a charm. I can't thank you enough for this walkthrough. It really, really helped.

Thanks again!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group