More in this section

Forums / Developing with Sitefinity / How do I make Category field required for events?

How do I make Category field required for events?

4 posts, 0 answered
  1. Marko
    Marko avatar
    148 posts
    Registered:
    30 Jul 2008
    18 May 2009
    Link to this post
    How do I make the "category" field a required one for adding and editing events?  In other words, I need it so that the users have to select one of the categories when they add or modify events?

    When I look at the markup of the Events control templates, they have this for the Category field:

    <sfCtg:CategoriesField ID="Category" runat="server" />

    ... and I don't know how to make that required.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 May 2009
    Link to this post
    Hello Marko,

    I sent the same reply to your support request. I will post the answer here if someone of the community has the same issues.

    You can set Categories metakey as required following the steps below:

    1. Map the external templates which for the required provider ( example NewsItemNew, NewsItemEdit.)
    2. Then modify ContentCategoriesField control as below:

    <sf:ContentCategoriesField ID="Category" runat="server"  LayoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/CategoriesField.ascx"></sf:ContentCategoriesField> 

    By doing so you are mapping the external template for ContentCategoriesField control.

    3. Modify ContententCategoriesField control template using Validator:

    <%@ Control Language="C#" %> 
    <%@ Register Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" TagPrefix="telerik" %> 
    <asp:Label runat="server" ID="lbl" Text="MAPPED"></asp:Label> 
    <telerik:RadComboBox ID="categoriesList" EnableEmbeddedSkins="true" Skin="WebBlue" runat="server"></telerik:RadComboBox> 
    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" 
    ControlToValidate="categoriesList" 
    InitialValue="* Uncategorized *" 
    ErrorMessage="Please select category" 
    ValidationGroup="InsertNews"/> 
     

    Just to let you know this approach works only in Sitefinity versions 3.6x. The control in the previous versions is different and its container is private which means that it cannot be accessed.


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. shae
    shae avatar
    30 posts
    Registered:
    26 Jul 2012
    21 May 2009
    Link to this post
    Will this work the same for adding new items to a library?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 May 2009
    Link to this post
    Hello shae,

    When you upload images you use LibraryItematchEdit template - the control resposible for managing Categories is the same ContentCategoriesfiels. The scenarion there is the same.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered