Copied to clipboard

Flag this post as spam?

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


  • Daniela Edemann 7 posts 20 karma points
    Mar 05, 2009 @ 10:02
    Daniela Edemann
    0

    Create datatype for password

    Hi

    How do I create a datatype for the administration, where the user can type a password whithout showing the characters?
    As if I created a passwordtype on a website etc:

    Thank in advance

    Daniela Edemann

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Mar 05, 2009 @ 10:15
    Ismail Mayat
    1

    Daniela,

    Tim has written excellent article with source code on his blog about creating your own datatypes.

    Regards


    Ismail

  • Graham Davis 110 posts 376 karma points
    Nov 14, 2017 @ 14:01
    Graham Davis
    0

    I need to do that same thing that Daniela has described and would LOVE to see this added to a future version of Umbraco.

  • Ben Palmer 176 posts 842 karma points c-trib
    Nov 14, 2017 @ 20:03
    Ben Palmer
    1

    Very bare bones example but Umbraco is great for extending so this should get you on your way:

    First, create a package.manifest file, in this example it sits at: ~/App_Plugins/Sandbox/package.manifest. The Sandbox directory is a newly created on just for the plugin. The file looks something like this:

    {
        propertyEditors: [
            {
                alias: "UmbracoSandbox.Password",
                name: "Password",
                icon: "icon-code",
                editor: {
                    view: "~/App_Plugins/Sandbox/views/Password.html"
                }
            }
        ],
        javascript: [
            '~/App_Plugins/Sandbox/assets/js/Password.Controller.js'
        ]
    }
    

    Then, we need to create an Angular controller which isn't strictly necessary but will give you something to hook into should you need to add functionality. This sits in our newly created plugin directory: ~/App_Plugins/Sandbox/assets/js/Password.Controller.js. That goes something like this:

    angular.module('umbraco').controller('UmbracoSandbox.PasswordController', passwordController);
    function passwordController($scope) {
        console.log($scope.model);
    }
    

    Finally, we create the view which displays the field in the admin area. This sits at ~/App_Plugins/Sandbox/views/Password.html and looks like this:

    <div ng-controller="UmbracoSandbox.PasswordController">
        <input type="password" name="textbox" ng-model="model.value" class="umb-editor umb-textstring textstring" />
    </div>
    

    Once this is done, you'll need to go into Developer -> Data Types and create a new Password data type for it to be available in your doc types.

    As simple as that.

    Just to note that there's no structure that Umbraco expects here part from the package.manifest file being in the root of your new plugin directory. Assets, views etc can live anywhere you like as long as you point your manifest file to the right place.

    Hope that helps :)

Please Sign in or register to post replies

Write your reply to:

Draft