Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I create custom property editor which takes all available languages in Umbraco like:
angular.module("umbraco").controller("MyLanguageController", function ($scope, myLanguageService) { $scope.items = []; myLanguageService.getAll().then( function( result ) { if( result && result.data && result.data.length ) { $scope.items = result.data; } } ); });
and
angular.module("umbraco.resources") .factory("myLanguageService", function ($http) { return { getAll: function () { return $http.get("/umbraco/backoffice/MyControllerSide/GetAll", { "dataType": "json" }); } }; });
The view:
<div ng-controller="MyLanguageController" id="language"> <ul> <li ng-repeat="item in items" class="checkbox"> <label> <input type="checkbox" value="{{item.IsoCode}}"> {{item.CultureName}} </label> </li> </ul> </div>
The package manifest contains:
{ propertyEditors: [ { alias: "MyLanguageAlias", name: "Language Selector", icon: "icon-umb-translation", hideLabel: true, valueType: "JSON", editor: { view: "~/App_Plugins/MyLanguageSelector/backoffice/view.html" } } ], ...
and C# code:
[HttpGet] public JsonResult GetAll() { IEnumerable<ILanguage> languages = ApplicationContext.Services.LocalizationService.GetAllLanguages() ?? new List<ILanguage>(0); IEnumerable<TranslationLanguageModel> model = languages.Select(s => new MyLanguageModel { CultureName = s.CultureInfo.DisplayName, IsoCode = s.IsoCode }); return Json(model, JsonRequestBehavior.AllowGet); }
I created new data type in Umbraco/Developer section, and I add it in document type:
When I save document, the value for that property is null. I don't understand why.
And when come back to content, then nothing is checked.
What should I do ?
Hi,
Because you don't store the value you need.
<input type="checkbox" value="{{item.IsoCode}}"> {{item.CultureName}}
There is not enough parts of the code like this. But, this code you need check.
<input type="checkbox" ng-model="model.value" value="{{item.IsoCode}}"> {{item.CultureName}}
Another example
You may need to add a new method that will call when you select some options and will save the correct value in the model.value in angular controller.
Regards,
Vitaly
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Data is not saved if use custom property editor in Umbraco
I create custom property editor which takes all available languages in Umbraco like:
and
The view:
The package manifest contains:
and C# code:
I created new data type in Umbraco/Developer section, and I add it in document type:
When I save document, the value for that property is null. I don't understand why.
And when come back to content, then nothing is checked.
What should I do ?
Hi,
Because you don't store the value you need.
There is not enough parts of the code like this. But, this code you need check.
Another example
You may need to add a new method that will call when you select some options and will save the correct value in the model.value in angular controller.
Regards,
Vitaly
is working on a reply...