+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Question: IDynamicFieldContainer

Question: IDynamicFieldContainer

3 posts, 2 answered
  1. Agustin
    Agustin avatar
    7 posts
    Registered:
    22 Apr 2013
    02 Jan 2014
    Link to this post

    Does anyone know the interfaces that need to be implemented by a custom type in order to enable custom field support in sitefinity? 

    My custom type is currently implementing IContent, IDynamicFieldContainer and is editiable in the UI however Sitefinity does not enable support for custom fields.  I think I am missing an interface or perhaps a setting on the module configuration. 

    The type is hosted in a native custom module (via thunder) not a dynamic module (via module builder) 

    I am hoping someone has previously run into this issue and point me in the right direction.  

     

     

    Answered
  2. Stefani Tacheva
    Stefani Tacheva avatar
    718 posts
    Registered:
    21 Nov 2016
    07 Jan 2014
    Link to this post
    Hello,

    Please refer to our official documentation for creating custom fields programaticaly:

    http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/modules/ecommerce/product-types/custom-fields/creating-custom-fields

    If you are adding these fields for a custom module I would suggest you to review these forum threads:

    http://www.sitefinity.com/developer-network/forums/sitefinity-sdk/adding-custom-fields-option-to-custom-modules

    Regards,
    Stefani Tacheva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Agustin
    Agustin avatar
    7 posts
    Registered:
    22 Apr 2013
    17 Jan 2014 in reply to Stefani Tacheva
    Link to this post

    In order for a custom content type to implement IDynamicFieldContainer the following steps need to be performed:

    1 - Your custom content type class must inherit the IDynamicFieldContainer marker interface

    2 - Your custom content type must be marked with the TypeDescriptionProvider attribute with typeof(DynamicFieldsTypeDescriptionProvider) as its first argument

    [TypeDescriptionProvider(typeof(DynamicFieldsTypeDescriptionProvider))]
    public class MyCustomContentType : IDataItemIDynamicFieldsContainer 
    


     

    3 - You must override the SupportDynamicTypes property in your MetadataSource and return true

    public class MyContentTypeMetadataSource : SitefinityMetadataSourceBase 
    {
        protected override bool SupportDynamicTypes
        {
            get
            {
                return true;
            }
        }
     
        // other code removed for brevity    
    }

     

     

     

    4 - Use the MetadataManager.CreateMetaType() method to register the type

    5 - Use the App.WorkWith().DynamicData() Façade to create your custom fields definition.

    Note:  Please note that the assembly version for your assembly is used to determine if the metadata schema update needs to be performed.

     

    Answered
3 posts, 2 answered