I found out that it will save the value if i preset the $scope.model.value to start with an array with a value in it, but it wont save an empty value or array.
This wont save it
$scope.model.value = undefined;
// OR
$scope.model.value = null;
// OR
$scope.model.value = [];
Not sure if this is still an issue for you as it's been a little while but I wanted to try and help as I came across the same issue this week. The only difference is that I'm using a content picker as opposed to your URL picker. The same process and reasoning though, of course :)
The way I solved it was by making sure the $scope.model.value variable was set in the vm.{picker}.value watch, which you are already doing (great!) and to ensure the correct/required config values are set - what I mean by this is, after debugging Umbraco's content picker controller JS, I could see that the 'idType' value needed to be set, as by default it uses ID and not the UDI format, which my code was using. Strangely you wouldn't think this was needed as I thought UDI was the default now, but hey ho. So rather than just setting the min and max numbers in the config, look at Umbraco's base implementation (umbraco.controllers.js) and either find the required one or maybe just add them all and go from there. Also, I didn't need to include any watchers for formSubmitting.
I hope this helps you and anyone else who is on their journey of custom property editors but wanting to reuse Umbraco's property editors :) I'm starting to get involved in Umbraco and the community so perhaps I'll write a blog post on this topic soon. Let me know if you need any further assistance.
umb-property-editor with multiurlpicker view wont save my scope model value
Hi all.
When i save and publish the page my $scope.model.value does not get updated. Well it does until i reload the page :)
formSubmitting is firing first and then watch and maybe thats why the model dont get updated. what can i do? or what do i do wrong?
Umbraco.PropertyEditors.MultiUrlPickerController is using formSubmitting to set the value.
I found out that it will save the value if i preset the $scope.model.value to start with an array with a value in it, but it wont save an empty value or array.
This wont save it
This will save changes, unless the value is empty
So what to do?
Hi Bo :)
Not sure if this is still an issue for you as it's been a little while but I wanted to try and help as I came across the same issue this week. The only difference is that I'm using a content picker as opposed to your URL picker. The same process and reasoning though, of course :)
The way I solved it was by making sure the $scope.model.value variable was set in the vm.{picker}.value watch, which you are already doing (great!) and to ensure the correct/required config values are set - what I mean by this is, after debugging Umbraco's content picker controller JS, I could see that the 'idType' value needed to be set, as by default it uses ID and not the UDI format, which my code was using. Strangely you wouldn't think this was needed as I thought UDI was the default now, but hey ho. So rather than just setting the min and max numbers in the config, look at Umbraco's base implementation (umbraco.controllers.js) and either find the required one or maybe just add them all and go from there. Also, I didn't need to include any watchers for formSubmitting.
I hope this helps you and anyone else who is on their journey of custom property editors but wanting to reuse Umbraco's property editors :) I'm starting to get involved in Umbraco and the community so perhaps I'll write a blog post on this topic soon. Let me know if you need any further assistance.
is working on a reply...