Search code examples
c#c1-cms

Configure a field with a Widget Type on a Data Type using C#


I'm currently working on a new site based on Composite C1 5.0 I'm looking at having as much as possible regarding Data Types in c# code, but I can't find how to associate a Widget Type for a field in C#. I've looked through the Composite C1 documentation regarding Data types but can't find if this is possible. I can however configure a widget type in Composite, but then I'm dependant on the generated Xml file holding this information.

Is this possible?

Best regards


Solution

  • You can add the FormRenderingProfileAttribute attribute to your DataType Property like this

    [FormRenderingProfile(Label = "Title", HelpText = "Help for title", WidgetFunctionMarkup = "...")]
    string Title { get; set; }
    

    https://github.com/Orckestra/C1-CMS/blob/master/Composite/Data/FormRenderingProfileAttribute.cs

    Assign this to properties on your IData interfaces to control how a data field whould be viewed and edited in a form view.