Copied to clipboard

Flag this post as spam?

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


  • anthony hall 222 posts 536 karma points
    May 13, 2013 @ 12:16
    anthony hall
    0

    Hiding field types

    I've created a collection of custom field types. These contain a few more properties than the default fields. Is there a way to disable default field types such as "text field" in the form editor.

    For example when you click add field you will only see the custom fields

     

  • Jonathan 19 posts 101 karma points
    Sep 04, 2015 @ 06:42
    Jonathan
    0

    I'm looking for the same option in the latest Umbraco 7.2 | Forms. In the CMS I would like to hide a few default field types for the Form editor.

    Anybody any idea if this is possible?

  • Jonathan 19 posts 101 karma points
    Sep 15, 2015 @ 13:43
    Jonathan
    0

    Fixed it in Umbraco 7.2.8 without having to change core files. Did it by creating a new folder (package) in App_Plugins with only a javascript file and a package manifest which references the javascript file.

    Luckily Umbraco will always automatically load this script, also on the Forms pages in the CMS.

    The javascript file is an Angular directive which overrides the fieldtypes array that Forms uses to load the available fieldtypes when creating a new field.

    angular.module('umbraco.directives').config(function ($provide) {
    $provide.decorator('umbFormsDesignerDirective', ['$delegate', function ($delegate) {
        var directive = $delegate[0];
        var link = directive.link;       
    
        directive.compile = function () {
            return function (scope, element, attrs) {
    
                var filtered = [];
                var fieldsToRemove = [
                    "Textfield",
                    "Textarea",
                    "CheckBox",
                    "File upload",
                    "Password Field",
                    "CheckBoxList",
                    "DropDownList",
                    "RadioButtonList",
                ];
    
                _.each(scope.fieldtypes, function(item) {
                    if (!_.contains(fieldsToRemove, item.name)) {
                        filtered.push(item);
                    }                
                });
    
                scope.fieldtypes = filtered;
    
                 link.apply(this, arguments);
                 return;
             };
         };
    
        return $delegate;
    }]); });
    
Please Sign in or register to post replies

Write your reply to:

Draft