Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Luke 11 posts 91 karma points
    Feb 25, 2022 @ 16:13
    Luke
    0

    Forms 9 overriding default fieldtypes

    Previously in Umbraco 8.x and Forms 8.x I was able to override default fieldtypes in Umbraco Forms.

    I did this by inheriting for example the standard CheckBox type and changing the HideLabel property to true:

    public class CheckBox : global::Umbraco.Forms.Core.Providers.FieldTypes.CheckBox
    {
        public CheckBox()
        {
            this.HideLabel = true;
        }
    }
    

    I want to do the same in the new Umbraco 9.3.1 with Umbraco Forms 9.2.2 but it doesn't seem to pick up the changes that I make. I have tried the code shown above and also by overriding the hidelabel property like this

            public override bool HideLabel => true;
    

    However neither of these seem to be picked up. The code doesn't look to be executed. I checked this by editing the Name of the fieldtype, these changes aren't reflected in the backoffice either.

    Has anyone tried this in Umbraco 9 and how did you solve this?

  • Warren 3 posts 94 karma points
    Sep 27, 2022 @ 08:59
    Warren
    100

    Hello, I was struggling with this in umbraco 10 but have figured it out.

    You need to register your class the same way you'd register a new field see docs here

    So it'd look something like this:

    public class UmbracoFormsCustomProvidersComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder)
        {
            builder.WithCollectionBuilder<FieldCollectionBuilder>()
                .Add<CheckBox>();
        }
    }
    

    Hope this works for you if you've not already figured it out!

  • Luke 11 posts 91 karma points
    Sep 27, 2022 @ 11:56
    Luke
    0

    Hello Warren,

    I totally forgot about updating this post myself, I had figured it out the same way you did and ended up adding an IComposer to add the Checkbox just like you!

Please Sign in or register to post replies

Write your reply to:

Draft