Copied to clipboard

Flag this post as spam?

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


  • Patrick van Kemenade 101 posts 339 karma points
    Jan 07, 2021 @ 14:04
    Patrick van Kemenade
    0

    I'm creating a custompropertyeditor called buttonLink which I can use in a grid in Umbraco 8.9.1.

    So far I'm able to create one which looks good in the backend, meaning I can pick a content item, but when saving (or previewing) I see the selected vlaue is not stored/retainded. The other value "Button text" is stored.

    What do I need to change ?

        \gridpropertyeditors\LinkButton.cshtml
    
    <div ng-controller="Positioner.LinkButtonController">
        <div>
            <label>
                Button text
            </label>
            <br />
            <input type="text" rows="1"
                   class="umb-property-editor umb-textstring textstring"
                   umb-auto-resize
                   umb-auto-focusclass="textstring input-block-level" ng-model="control.value.buttonText" placeholder="Button text" /><br /><br />
        </div>
    
        <div class="linkbutton-row">
            <label>internal link: </label>
            <div>
                <umb-property-editor model="contentPicker" ng-model="control.value.buttonLink"></umb-property-editor>
            </div>
        </div>
    </div>
    
    js\LinkButtonController.controller.js
    
    angular.module("umbraco")
        .controller("Positioner.LinkButtonController", function ($scope) {
            $scope.contentPicker = {
                view: 'contentPicker',
                config: {
                    minNumber: 0,
                    maxNumber: 1
                },
                value: $scope.model.value.InternalLink
            };
        });
    
    
    \linkButton.cshtml (I just want to see what is stored here ...)
    
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
    @using Umbraco.Web.Templates
    @Model
    
  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Jan 11, 2021 @ 21:09
    Marc Goodson
    1

    Hi Patrick

    When you press save in the backoffice, then whatever the value of $scope.model.value is for your custom property editor, is the value that gets persisted to the database.

    So I'm not sure from the parts of the files that you have posted need to be updated, there is a gist here of using a Content Picker in a custom property editor:

    https://gist.github.com/abjerner/a2b1cf55eab147dbcff2b68e79e04090

    that might give you a bit of a steer...

    regards

    marc

  • Patrick van Kemenade 101 posts 339 karma points
    Jan 12, 2021 @ 21:18
    Patrick van Kemenade
    0

    Thanks for your feedback and the example, tried it in Umbraco 8 but not much happening (can't even pick content) I'm afraid this is developed for Umbraco 7 and things changed a bit.

Please Sign in or register to post replies

Write your reply to:

Draft