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

Forums / Bugs & Issues / Custom Content Module SF 4.1 SP2+ / SF 4.2

Custom Content Module SF 4.1 SP2+ / SF 4.2

7 posts, 0 answered
  1. Thomas Weidman
    Thomas Weidman avatar
    38 posts
    Registered:
    19 Apr 2004
    11 Aug 2011
    Link to this post
    Hello-

    I have a custom module that is a copy of the Products Module that was customized to extend the standard content base module.  It has some additional fields all that work as expected.  The built in content fields (Title, Content, URL, etc...) do not save when the item is published or saved as a draft.  The code for this module worked perfectly in SF 4.1 SP1 and 4.1 but something has changed and it no longer works the same.

    I've looked at the blog post with the Sample Locations module and have even used it as a template and ran into the same issues.

    Any help or guidance on how to proceed would be appreciated.

    Thanks,

    -Thomas
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    11 Aug 2011
    Link to this post
    Hi Thomas,

    Please check whether you have created your custom fields for the ProductItem. You can use System.ComponentModel.TypeDescriptor.GetProperties( object);
    If the properties are not created you should add them

    App.WorkWith().DynamicData().Type(typeof(ProductItem)).Field().TryCreateNew("mycustomfield", null).SaveChanges();



    Greetings,
    Ivan Dimitrov
    the Telerik team
    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. Thomas Weidman
    Thomas Weidman avatar
    38 posts
    Registered:
    19 Apr 2004
    11 Aug 2011
    Link to this post
    Ivan-

    Yes they are there.  My custom fields save and load perfectly.  The only fields that do not load are the ones provided as part of the base content object.

    Thanks,

    -Thomas
  4. R. Atanasov
    R. Atanasov avatar
    19 posts
    Registered:
    03 Nov 2014
    16 Aug 2011
    Link to this post
    Hello Thomas,

    Excuse us for the belated response.

    Could you send us your project and database (or give us a link to download from if those are more than the allowed attachment size)? This will allow us to diagnose the issue much more quickly.

    Regards,
    Radoslav Atanasov
    the Telerik team
    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
  5. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    26 Aug 2011
    Link to this post
    I'm having the same issue even with a vanilla install of the products module. The title and the description are not saving although all the other items are (e.g. color, price, quanity). I tried the products module directly because I was having a similar issue with a custom module. Any information on how to avoid this?
  6. Nikolay Datchev
    Nikolay Datchev avatar
    87 posts
    Registered:
    01 Nov 2016
    29 Aug 2011
    Link to this post
    Hi Kmac and Thomas,
    Can you check your ProducstDefintions.cs file for the definition of the title and content  field controls.

    The most current definition should be like the quoted bellow (notice the usage of "Title.PersistedValue" for DataFieldName). The PersistedValue property is used only when binding Lstring fields(multilingual text fields), this property is used because one can optionally write a Resource expression that is later evaluated as real text from a resource package. So the PersistedValue is the original expression (or plain text), and Value(the default property) - keeps the evaluated expression or plain text. Bottom line is that we now bind all multilingual fields to PersistedValue in Edit mode and if your module is using old code that doesn't saving of this fields would not work.

    var titleField = new TextFieldDefinitionElement(mainSection.Fields)
                {
                    ID = "titleFieldControl",
                    DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Title.PersistedValue" : "Title",
                    DisplayMode = displayMode,
                    Title = "lTitle",
                    CssClass = "sfTitleField",
                    ResourceClassId = typeof(ProductsResources).Name,
                    WrapperTag = HtmlTextWriterTag.Li,
                };

    also for the Content field (notice the usage of Content.PersistedValue:


                var contentField = new HtmlFieldElement(mainSection.Fields)
                {
                    ID = "contentFieldControl",
                    DataFieldName = (displayMode == FieldDisplayMode.Write) ? "Content.PersistedValue" : "Content",
                    DisplayMode = displayMode,
                    CssClass = "sfFormSeparator sfContentField",
                    ResourceClassId = typeof(ProductsResources).Name,
                    WrapperTag = HtmlTextWriterTag.Li,
                    EditorContentFilters = Telerik.Web.UI.EditorFilters.DefaultFilters,
                    EditorStripFormattingOptions = (Telerik.Web.UI.EditorStripFormattingOptions?)(Telerik.Web.UI.EditorStripFormattingOptions.MSWord | Telerik.Web.UI.EditorStripFormattingOptions.Css | Telerik.Web.UI.EditorStripFormattingOptions.Font | Telerik.Web.UI.EditorStripFormattingOptions.Span | Telerik.Web.UI.EditorStripFormattingOptions.ConvertWordLists)
                };
                mainSection.Fields.Add(contentField);

    Same goes for the UrlName field it should use:
    DataFieldName = (displayMode == FieldDisplayMode.Write) ? "UrlName.PersistedValue" : "UrlName", 



    Regards,
    Nikolay Datchev
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  7. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    29 Aug 2011
    Link to this post
    That worked like a charm, Nikolay. Thank you. I just used the productmodule visual studio template that comes with the SDK to get started so I think you might need to update that code in there.

    Thanks again
7 posts, 0 answered