Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10059 karma points MVP 2x admin c-trib
    Dec 05, 2019 @ 17:09
    Ismail Mayat
    0

    Example code for property editor with custom prevalues in v8

    Can anyone point me to some sample code for property editor for v8 with prevalues? I am migrating similarity package v7 to v8. As it stands the save of prevalues is not working i get the following error:

    angular.js?cdv=1:15536 Possibly unhandled rejection: {"errorMsg":"Failed to retrieve data for data type id undefined","data":{"Message":"The request is invalid.","MessageDetail":"The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'Umbraco.Web.Models.ContentEditing.DataTypeDisplay GetById(Int32)' in 'Umbraco.Web.Editors.DataTypeController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."},"status":400

    Part of my manifest for prevalues part looks like:

    prevalues: {
                fields: [
                    {
                        label: "Index",
                        description: "Index to search on",
                        key: "index",
                        view: "~/App_Plugins/Similarity/views/prevalueEditor/indexes.html",
                        validation: [
                            {
                                type: "Required" 
                            }                       
                        ]
                    },
                    {
                        label: "Number of docs",
                        description: "Maximum number of documents to return",
                        key: "maxNo",
                        view: "number",
                        validation: [
                            {
                                type: "Required" 
                            }                       
                        ]
                    }
    

    My controller for the custom prevalue editor looks like:

    angular.module("umbraco").controller("similarity.indexController",
        function ($scope, indexResource) {
    
            vm = this;
    
            indexResource.getAllIndexes().then(function(response) {
    
                vm.indexes = response.data;
    
            });
        });
    

    In my view i have:

    <div ng-controller="similarity.indexController as vm">
            <select ng-model="vm.value.index" class="umb-property-editor umb-dropdown" ng-options="index.IndexDirectory as index.IndexName for index in vm.indexes">                
                <option>choose an index</option>
            </select>       
    

    When i save i get errors. I suspect its something todo with

    ng-model="vm.value.index"
    

    The binding on the select?

    Anyone any suggestions?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies