Developer forum

Forum » CMS - Standard features » Code-first Item Tab field

Code-first Item Tab field

Jesse Bakker
Reply

Hi,

In 9.5.1 there is a new itemfield introduced, the Item Tab. 
When I create a item field from the Admin with this type it works fine. 

But I can't use it on a code-first ItemType. I can't find an editor attribute to use. 

I've tried to use the regular ItemType editor and set the EditorType to ItemTypeTabEditor. But then it turns into a regular ItemType editor.
Like this:

[ItemTypeEditor("Image", "ParagraphImage", EditorType = typeof(ItemTypeTabEditor))]
public string ImageID { get; set; }
 
Am I missing an attribute? Or is there another way of declaring the editor to get it working?
 
Br, Jesse
 
 

 


Replies

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply
This post has been marked as an answer

Hi Jesse,

It seems a solution is to define the new attribute in your code:

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class ExampleItemTabEditorAttribute : ItemTypeEditorAttribute
    {
        public ExampleItemTabEditorAttribute(string name, string itemType) : base(name, itemType)
        {
            EditorType = typeof(ItemTypeTabEditor);
        }
        protected override void InitializeEditorConfiguration(ItemField itemField)
        {
            var itemListEditor = new ItemTypeTabEditor() { ItemType = ItemType };
            itemField.EditorConfiguration = itemListEditor.GetParametersToXml(false);
        }
    }

Best regards,

Vladimir

Votes for this answer: 1
 
Jesse Bakker
Reply

Hi Vladimir,

Thanks for the code, it worked.

Br, Jesse

 

You must be logged in to post in the forum