Custom Property editor with multiple fields - validation
Hi All,
Just after some pointers on how I can apply my own validation logic to a custom property editor that has multiple fields. Basically if when a property using the custom editor is added and the property is set to mandatory I want to be able to apply my own logic to mandatory check.
The reason being the property editor has to have certain fields completed in order to make it valid else it is considered incomplete.
angular.module("umbraco")
.controller("My.MarkdownEditorController",
function ($scope) {
$scope.myValidateFunction = function () {
//set isValid too true so that if this property isnt marked as mandatory on the document type the property is allways valid
var isValid = true;
if ($scope.model.validation.mandatory) {
var inputValue = $scope.model.value;
var intValue = parseInt(inputValue);
isValid = intValue % 2 === 0;
}
return {
isValid: isValid,
errorMsg: "Value cannot be empty",
errorKey: "myCustomValidationKey"
};
}
});
Manifest
{
//you can define multiple editors
propertyEditors: [
{
/*this must be a unique alias*/
alias: "My.MarkdownEditor",
/*the name*/
name: "Markdown editor",
/*the html file we will load for the editor*/
editor: {
view: "~/App_Plugins/MarkDownEditor/markdowneditor.html"
}
}
]
,
//array of files we want to inject into the application on app_start
javascript: [
'~/App_Plugins/MarkDownEditor/markdowneditor.controller.js'
]
}
Custom Property editor with multiple fields - validation
Hi All,
Just after some pointers on how I can apply my own validation logic to a custom property editor that has multiple fields. Basically if when a property using the custom editor is added and the property is set to mandatory I want to be able to apply my own logic to mandatory check.
The reason being the property editor has to have certain fields completed in order to make it valid else it is considered incomplete.
Thanks,
Nik
This is a quick and dirty example i made that uses my own validation on a property field.
View
Controller
Manifest
You can also check the Umbraco Source Code for an example https://github.com/umbraco/Umbraco-CMS/tree/9290f61f9485c5bef0aa9a95e05e8acefa9ce221/src/Umbraco.Web.UI.Client/src/views/propertyeditors/tags
is working on a reply...