none
content types as choice field on newForm.aspx RRS feed

  • Question

  • Hello,

    I use sharepoint 2010 server Enterprise.

    I need to display content types in a choice field on a newForm.aspx . After user choose content type, newform must show corresponding fields.

    Is there any way to do this? I heared that there is a default column named Content Type but i cant find it.

    Tuesday, November 2, 2010 7:14 AM

Answers

  • Each content type has its own newForm.aspx.  When added to a list you choose which content type (which newForm.aspx) you want to use on the dropdown of the new button.  By the time you get to the newForm.aspx you are already committed to a specific content type.
    Paul Stork SharePoint Server MVP
    Tuesday, November 2, 2010 12:23 PM
  • yes, you should create a custom newform for each content type.  But I'm not sure you will be able to change the form after creating an item using the default content type.  Why don't you just use the dropdown on the New button?  Why do you need to change the content type of the item after its already been started?  It might work, but you are definately trying to fight the logic built into the system.
    Paul Stork SharePoint Server MVP
    Tuesday, November 9, 2010 6:15 PM

All replies

  • Each content type has its own newForm.aspx.  When added to a list you choose which content type (which newForm.aspx) you want to use on the dropdown of the new button.  By the time you get to the newForm.aspx you are already committed to a specific content type.
    Paul Stork SharePoint Server MVP
    Tuesday, November 2, 2010 12:23 PM
  • Hi Nikita,

    this is the default behavior when multiple content types are assigned to a single list. To enable diffenent content types on a list or library you must go to List settings -> advance list settings  and then set "allow management of content types" to yes. In List settings a new configuration section came up regarding the content type. Now you be able to add another content types to the list. This will work the same way for lists and libraries.

    After you add another content type to the list you will be able to choose the content type on newform.aspx So you don't need to add any content type column. Yes there is a content type column but this column is hidden and only for internal use.

    As Paul said ever content type can have it's own new or edit form but the default newform.aspx is able to handle different content types and shows only the columns belonging to the content type.

    Regards Stefan


    http://www.n8d.at/blog
    MCTS - SharePoint / WSS Configuration and Development
    Tuesday, November 2, 2010 7:28 PM
  • Stefan,

    Where have you seen the behavior that you can pick a content type on the NewForm?  I've seen a content type dropdown when you upload files to a document library, but in every list I've ever worked with clicking the add item link always brings up the default content type newform.  the only way I've ever seen to choose which kind of content type is by using the dropdown on the new button in the list.  That's on the ribbon not on the newform.  By the time the newform comes up you are already committed to a content type. 

    I'm not trying to start an argument, but I'm curious what you are seeing that I am not.


    Paul Stork SharePoint Server MVP
    Tuesday, November 2, 2010 8:58 PM
  • Paul,

    thanx you are right. What missleaded me was that after a upload of a document you get the content type selection and if you edit a item of a list you will get that too. The NewForm.Aspx only gets the content type form the default content type defined on the list or by the query string ContentTypeId=<ContentTypeID>. The Query parameter is what the New Button does.

    I added for testing some content types to a custom list an the Urls look like this:
    for Item Content Type:   
    http://myserver/Lists/CustomList/NewForm.aspx?RootFolder=%2FLists%2FCustomList&ContentTypeId=0x01001F4E17A590CC8E4998BE646AEA065BFE
    for Blog Post Content Type:
    http://myserver/Lists/CustomList/NewForm.aspx?RootFolder=%2FLists%2FCustomList&ContentTypeId=0x0110003B2AD800EDDEBF4CA95E58CC3D6F0B65
    for Task Content Type:
    http://myserver/Lists/CustomList/NewForm.aspx?RootFolder=%2FLists%2FCustomList&ContentTypeId=0x010800BE41273685637045AFE63AB155E98730

    Just added some random content types to a custom list. It might would be possible to redirect from a drop down box using javascript to the specific NewForm but it's not out of the box avaliable.

    Regards Stefan


    http://www.n8d.at/blog
    MCTS - SharePoint / WSS Configuration and Development
    Tuesday, November 2, 2010 10:39 PM
  • So just to clarify. I have to create custom newform's for all my content types and 1(default) for a dropdown with cntent types. When user choose content type onChange event we load corresponding newForm. 
    Tuesday, November 9, 2010 5:08 AM
  • yes, you should create a custom newform for each content type.  But I'm not sure you will be able to change the form after creating an item using the default content type.  Why don't you just use the dropdown on the New button?  Why do you need to change the content type of the item after its already been started?  It might work, but you are definately trying to fight the logic built into the system.
    Paul Stork SharePoint Server MVP
    Tuesday, November 9, 2010 6:15 PM
  • For items - In \ 14 \ Template \ CONTROLTEMPLATES \ DefaultTemplates.ascx
     Copy the "ListForm" template (<SharePoint:RenderingTemplate id="ListForm" runat="server">) and change the name of "NewListForm" for example. Append ControlMode = "Edit" to ChangeContentType node. Save changes. In SPD NewForm.aspx change code as <TemplateName xmlns="http://schemas.microsoft.com/WebPart/v2/ListForm"> NewListForm </ TemplateName>. Save changes. Restart IIS.
     - The document library must be the same, but use DocumentLibraryForm template

      Of course it is better to create your own ascx file and do not touch on DefaultTemplates.ascx

     

    <SharePoint:RenderingTemplate id="NewListForm" runat="server">
    	<Template>
    		<span id='part1'>
    			<SharePoint:InformationBar ID="InformationBar1" runat="server"/>
    			<div id="listFormToolBarTop">
    			<wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&amp;#160;" runat="server">
    					<Template_RightButtons>
    						<SharePoint:NextPageButton runat="server"/>
    						<SharePoint:SaveButton runat="server"/>
    						<SharePoint:GoBackButton runat="server"/>
    					</Template_RightButtons>
    			</wssuc:ToolBar>
    			</div>
    			<SharePoint:FormToolBar ID="FormToolBar1" runat="server"/>
    			<SharePoint:ItemValidationFailedMessage ID="ItemValidationFailedMessage1" runat="server"/>
    			<table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
    			<SharePoint:ChangeContentType ID="ChangeContentType1" ControlMode="Edit" runat="server"/>
    			<SharePoint:FolderFormFields ID="FolderFormFields1" runat="server"/>
    			<SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server"/>
    			<SharePoint:ApprovalStatus ID="ApprovalStatus1" runat="server"/>
    			<SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows" runat="server"/>
    			</table>
    			<table cellpadding="0" cellspacing="0" width="100%"><tr><td class="ms-formline"><img src="/_layouts/images/blank.gif" width='1' height='1' alt="" /></td></tr></table>
    			<table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px"><tr><td width="100%">
    			<SharePoint:ItemHiddenVersion ID="ItemHiddenVersion1" runat="server"/>
    			<SharePoint:ParentInformationField ID="ParentInformationField1" runat="server"/>
    			<SharePoint:InitContentType ID="InitContentType1" runat="server"/>
    			<wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&amp;#160;" runat="server">
    					<Template_Buttons>
    						<SharePoint:CreatedModifiedInfo runat="server"/>
    					</Template_Buttons>
    					<Template_RightButtons>
    						<SharePoint:SaveButton runat="server"/>
    						<SharePoint:GoBackButton runat="server"/>
    					</Template_RightButtons>
    			</wssuc:ToolBar>
    			</td></tr></table>
    		</span>
    		<SharePoint:AttachmentUpload ID="AttachmentUpload1" runat="server"/>
    	</Template>
    </SharePoint:RenderingTemplate>
    • Proposed as answer by Martin Hatch Sunday, July 3, 2011 5:08 PM
    Monday, January 10, 2011 2:10 PM
  • hi all, my requirement is for the user to have a Content Type Selection in the Custom Edit Form, which has a listfielditerator. Also, when the user changes the Content Type, in Javascript, I add the Content Type to the QueryString and when the page loads back, I get the controls of the other content type. Now when the code hits the LIstFieldIterator.Item.Update(), it reverts back to the default content type of the document library, irrespective of whatever Content Type the user has chosen. 

    Any ideas?

    Saturday, January 22, 2011 4:14 PM