U4-10507 - Skip Property Validations for Content Templates

Created by Nicholas Westby 06 Oct 2017, 18:18:11 Updated by Dan Booth 12 Mar 2018, 10:12:44

When you create a content template, I just discovered that you are required to enter required field values (i.e., you can't save unless you pass the validations):


In this case, the "Code" property is required.

The problem with that is that I want the content editor to fill in that value when they create the content node. If I populate it with a dummy value as part of a content template, there is a strong likelihood that the content editor will forget to specify a correct value for that field.

Umbraco 7.7.2.

1 Attachments


Mike Chambers 31 Oct 2017, 00:10:22

rather than remove in the blueprint itself, you could remove from any newnode created from the blueprint? inspiration from http://issues.umbraco.org/issue/U4-2670#comment=67-25903 could extend to hide the clearFromBlueprint property from all but when editing ContentTemplates, and a property picker instead of the csv textstring.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Core;
using Umbraco.Web.Editors;

namespace SYP
    /// <summary>
    /// Summary description for testing
    /// </summary>
    public class EventStuff : ApplicationEventHandler
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            EditorModelEventManager.SendingContentModel += (sender, e) =>
                // we are creating from a blueprint so reset the values indicated
                // NB actual editing of contenttemplates doesn't seem to utilise the SendingContentModel so is unaffected
                if (e.Model.IsBlueprint)
                        //simple textstring on the doctype, csv of property aliases to clear
                        var clearFromBlueprintProperty = e.Model.Properties.Where(p => p.Alias == "clearFromBlueprint").FirstOrDefault();

                        if (clearFromBlueprintProperty != null)
                            foreach (var prop in (clearFromBlueprintProperty.Value as string).Split(','))
                                var property = e.Model.Properties.Where(p => p.Alias == prop).FirstOrDefault();
                                if (property != null)
                                    property.Value = null;
                    catch { };

ps the contentTemplate editing interface doesn't seem to register with the SendingContentModel.. otherwise validation could be removed using the above approach, or maybe not.. ;-)

Dan Booth 12 Mar 2018, 10:12:44

I definitely agree that content templates shouldn't enforce validation when saving as it drastically reduces their usefulness.

Priority: Normal

Type: Feature (request)

State: Submitted


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.7.2, 7.7.4

Due in version:


Story Points: