I have Created a custom Checkbox field type by duplicating the out of the box checkbox field type.

Only changed the View.

Ideally , my purpose is to get the display text (Model.Title in the code snippet )for the field from a rich text field which might contain a link.

I have not changed the model in my new custom field type. When add the field in a form , display is correct but when checkbox is checked from a page it is not saved in the DB.

Below is the View:

@using Sitecore.ExperienceForms.Mvc.Html
@model Sitecore.ExperienceForms.Mvc.Models.Fields.CheckBoxViewModel

    string dbName = Sitecore.Context.Database.Name == "core" || Sitecore.Context.Database.Name == "master" ? "master": "web" ;
    Sitecore.Data.Database datbase = Sitecore.Configuration.Factory.GetDatabase(dbName);
    var consentItem = datbase.GetItem(new Sitecore.Data.ID(Constants.FormConsentTextItem));

    Model.Title = consentItem.Fields["ConsentText"].Value;

    <label class="@Model.LabelCssClass">
        <input type="checkbox" id="@Html.IdFor(m => Model.Value)" name="@Html.NameFor(m => Model.Value)" class="@Model.CssClass" @if (Model.Value) { <text> checked="checked" </text> } value="true" data-sc-tracking="@Model.IsTrackingEnabled" data-sc-field-name="@Model.Name" data-sc-field-key="@Model.ConditionSettings.FieldKey" @Html.GenerateUnobtrusiveValidationAttributes(m => Model.Value) />@Html.Raw(Model.Title)
        <input type="hidden" name="@Html.NameFor(m => Model.Value)" value="false" />
    @Html.ValidationMessageFor(m => Model.Value)

1 Answer 1


Make sure that Allow Save option is checked by navigating in content editor to your custom field /sitecore/Forms/Custom Form/Page/Section/Custom Field. If you don't have the checkbox present then you need to inherit the /sitecore/templates/System/Forms/Save Settings template on your custom checkbox field template

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.