Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using a Microsoft template for adding Training and Courses for people to register for. Everything is working fine, but I want to add a field to the Courses list. I want to add a field to indicate what type of staff this course is for, eg HR, Health & Safety, Admin, etc.

So I have searched all over for answers to this, the documentation on SharePoint is shocking, and I did the following:

  • Settings > Create Column on the Courses page.
  • Entered all necessary details
  • On DispForm, EditForm and NewForm (.aspx) added @fStaffType, Staff Type; to DataFields section. (Staff Type is the name of the field`)
  • On DispForm added a new row to display the data:

    <tr>
        <td width="190px" valign="top" class="ms-formlabel">
           <H3 class="ms-standardheader">
               <nobr>Staff Type</nobr>
           </H3>
        </td>
       <td width="400px" valign="top" class="ms-formbody">
           <xsl:value-of select="@fStaffType"/>
        </td>
    </tr>
    
  • On EditForm and NewForm added a new row to edit/enter data:

    <tr>
        <td width="190px" valign="top" class="ms-formlabel">
       <H3 class="ms-standardheader">
           <nobr>Staff Type</nobr>
       </H3>
        </td>
        <td width="400px" valign="top" class="ms-formbody">
            <SharePoint:FormField runat="server" id="ff12{$Pos}" ControlMode="New" FieldName="fStaffType" __designer:bind="{ddwrt:DataBind('i',concat('ff12',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@fStaffType')}"/>
            <SharePoint:FieldDescription runat="server" id="ff12description{$Pos}" FieldName="fStaffType" ControlMode="New"/>
        </td>
    </tr>
    

On EditForm and NewForm I get the error:

Error Rendering Control - ff12description_1

An unhandled exception has occured. Object reference not set to an instance of an object.

If I comment out the description it will show the first td (Field Name) but the second td is just empty.

Any help would be greatly appreciated!

EDIT: A related problem, don't know if I should create a new question or not. But Marc D Anderson answered below and I was able to add and display a new field. However, I can add a new Course perfectly but if I edit one, and change the Staff Type field, a new Course will be created at the current day and time. But if other fields are edited they edit correctly.

Any ideas?

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted

Many of the "Fabulous 40" templates have customized forms. (You'll probably debate the fabulous part of the name at this point.)

It looks like you are doing roughly the right things in the forms, but it's a little hard to tell where it's going south on you.

When you created the new column, did you give it a name of "fStaffType"? If not, that's the issue. If you named it "Staff Type", then the internal name (or StaticName) for the column is "Staff_x0020_Type". (The space in the name will be encoded.) EDIT: You can find the StaticName for a column by going into list settings and editing that column. The StaticName will be at the end of the URL as a Query String parameter. Depending on which characters you have used, it may bedouble encoded, like Staff%5Fx0020%5FType.

You don't need to add the column DisplayName and StaticName to the DiataFields section -- it doesn't really serve any obvious purpose, frankly. You'll just need to make sure that the column name in the SharePoint:FormField and SharePoint:FieldDescription matches the StaticName for the column name you've added.

The trailing "_1" in the error is part of the unique name that SharePoint gives each instance of that column in the page (you could be allowing edits to multiple items in the same form) by appending the value of the $Pos variable.

share|improve this answer
    
Yeah, didn't really understand the naming conventions. Changed fStaffType to Staff_x0020_Type and it works! Cheers! –  anothershrubery May 13 '11 at 12:31
    
Great! Added the trick to find out the internal name above. –  Marc D Anderson May 13 '11 at 12:35
    
Oh, just tried editing a course and it doesn't seem to save the value for Staff Type. Any idea? –  anothershrubery May 13 '11 at 12:43
    
Actually just checking. It seems to be creating a new Course on the current date and time...Why would it be doing this? It is fine when creating a new course. –  anothershrubery May 13 '11 at 12:54
add comment

Looks like ff12 is already defined somewhere else in the page and it's probably re-writing with _1 at the end.

  1. Can you just try drag and drop the field from the Data Source and let the designer figure out the field names?

OR

  1. Can you try adding the "Custom Edit Form" in another page and then copy the FieldDescription?
share|improve this answer
    
This is likely the issue, I've done extensive work on this template. –  PirateEric May 13 '11 at 11:58
    
ff12 is definitely not defined elsewhere. –  anothershrubery May 13 '11 at 12:26
add comment

I may have not read or got good grasp of your needs. Why not implement Content Type? You could have feature for your custom fields (aka columns) and set attribute like diplay on edit form=true, show on view = true (etc.)

share|improve this answer
    
The template provided from Microsoft is not built using content types. –  PirateEric May 13 '11 at 11:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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