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

Forums / Developing with Sitefinity / Custom field type not saved for dynamic module

Custom field type not saved for dynamic module

3 posts, 0 answered
  1. Ollie P
    Ollie P avatar
    9 posts
    Registered:
    06 Jan 2016
    18 Feb
    Link to this post

    I am using Sitefinity 8.0 and have created a custom field type to use a UK date format. I want to replace the standard date field type used in my dynamic modules.

    I updated a field by going to Settings > Advanced > DynamicModules > Controls > MyType > Views > MyTypeInsertView > Section > MainSection > Fields > MyDateField and changing the FieldType to 'MyProj.Web.UKDateField, MyProj.Web'.

    The dynamic module updates correctly, and the DynamicModulesConfig.config is updated, but as soon as the dynamic module is edited e.g. to add a new field, the config reverts back to the original type 'Telerik.Sitefinity.Web.UI.Fields.DateField, Telerik.Sitefinity'.

    How can ensure my custom field type is retained?  Where is the default type coming from? 

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    26 Sep 2016
    22 Feb
    Link to this post
    Hello Ollie,

    I am afraid that the current implementation is such that whenever a modification is made to the dynamic module, the definitions are regenerated and any customization is lost. Please refer to the below KB article for more details about this:

    http://www.sitefinity.com/developer-network/knowledge-base/details/custom-modifications-made-to-dynamic-module's-definitions-are-lost-after-updating-module-fields

    This is considered missing implementation and a feature request is logged related to this as noted in the above KB artcile. here is the link to the description of the feature request: http://feedback.telerik.com/Project/153/Feedback/Details/99570-module-builder-add-the-ability-to-preserve-customization-to-dynamicmodulesconfig

    You can subscribe to receive notifications for the feature request including new comments, votes, status changes by clicking on the "Follow this item" link. If you would like to unsubscribe, you can unfollow the item by removing "Following this item”.

    Unfortunately, there isn't a workaround available at the moment.

    Regards,
    Sabrie Nedzhip
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. K
    K avatar
    1 posts
    Registered:
    25 Feb 2016
    25 Feb
    Link to this post

    I’ve looked into this and I believe this should be possible by creating a custom/extended datepicker control template (.ascx) and binding via ViewMap (Administration - Settings - Controls –ViewMap)
    HostType: Telerik.Sitefinity.Web.UI.Fields.DateField, Telerik.Sitefinity
    LayoutTemplatePath: <path to ascx>
    As far as I understand this should replace all datepickers on the backend with the custom template. I believe the custom template doesn’t need any special markup but it needs to override JavaScript prototype methods that are responsible for creating the datepicker field.
    The first link below talks about customizing the datepicker field to change the time format from 24 hours to AM/PM. 
    Here’s a piece of JavaScript that does it:
    Telerik.Sitefinity.Web.UI.Fields.DateField.prototype._setDateTimeMode = function (dFormat, tFormat) {
    this._datePicker = jQuery("#" + this._datePickerId).datetimepicker(
    { dateFormat: dFormat, hourGrid: tFormat, timeFormat: 'hh:mm TT', minuteGrid: 10, beforeShow: this._datePickerOnPopupOpeningDelegate, onClose: this._datePickerOnPopupClosingDelegate, showOn: "focus", ampm: true }
    );
    I believe that it should be possible to change the dateFormat field (highlighted in yellow) to force it to render dates in UK format.

     

    Could you confirm if this is a workable solution?

3 posts, 0 answered