I do see the values in the dropdown, but I can't make it work - the value is not saved after I press save.
Here is my manifest
{
//you can define multiple editors
propertyEditors: [
{
alias: "My.MemberCompanyPicker", // this must be a unique alias
name: "Member Company Picker", // name, this will show in the backoffice
valueType: "STRING", // "INT", "DATETIME", "STRING" "TEXT" and "JSON"
editor: {
view: "~/App_Plugins/MemberCompanyPicker/index.html" // the html file we will load for the editor
}
}
]
,
//array of files we want to inject into the application on app_start
javascript: [
'~/App_Plugins/MemberCompanyPicker/membercompanypicker.controller.js'
]
}
My html file:
<div ng-controller="MyMemberCompanyPicker">
<select ng-model="selected">
<option ng-repeat="c in companies track by c.id" value="{{c.id}}">{{c.name}}</option>
</select>
</div>
I don't really understand how it's supposed to work and how Umbraco will understand which value to save. Another question is how is the saved value is going to be loaded during the next edit? Can't find the answers anywhere.
I briefly changed the property data type to textstring and updated the value. Then I changed the data type back to my custom property editor and I can see that the value is actually loaded to $scope.model.value
I updated my select to update $scope.model.value and made sure the value is changed. However it's still not saved when I save my changes.
What else can be missing?
P.S. I also tried your suggestion to assign my value to $scope.model but that didn't work.
not sure if that a typo in the documentation, but i might be worth moving that.
i would try just setting model.value to a fixed string and see if that gets set?
For more complex stuff you can subscribe to the formSubmitting event
inside your controller, and set values then but you really shouldn't need to do that for something this simple. e.g.
var unsubscribe = $scope.$on("formSubmitting", function (ev, args) {
// set something to $scope.model.value here.
});
Finally figured it out. My code was setting $scope.model.value, but at
the same time it was resetting the model object and removing other model fields and apparently it broke something in the Umbraco workflow.
Also worth noting that it doesn't support 'controller as' syntax.
Umbraco 7 doesn't save my custom property value
Hey guys,
I've created a custom property using AngularJS as described here: http://umbraco.github.io/Belle/#/tutorials/CreatingAPropertyEditor. Currently it's a simple dropdown which will load values from database, but currently I just use static data.
I use the last version - v7.3.7.
I do see the values in the dropdown, but I can't make it work - the value is not saved after I press save.
Here is my manifest
My html file:
And the controller:
I don't really understand how it's supposed to work and how Umbraco will understand which value to save. Another question is how is the saved value is going to be loaded during the next edit? Can't find the answers anywhere.
Can someone advice please?
Hi
If everything else is working (and it sounds like it is) you need to put the value you want saving into $scope.model
this probably just means changing $scope.selected to $scope.model in the controller and ng-model from selected to model in the html.
Kevin
Hi Kevin,
Thanks for reply. It makes more sense now.
I briefly changed the property data type to textstring and updated the value. Then I changed the data type back to my custom property editor and I can see that the value is actually loaded to $scope.model.value
I updated my select to update $scope.model.value and made sure the value is changed. However it's still not saved when I save my changes.
What else can be missing?
P.S. I also tried your suggestion to assign my value to $scope.model but that didn't work.
Hi
just looking at some code I have for a property editor (fairly simple one here), i noticed that in my manifest valueType is inside Editor
not sure if that a typo in the documentation, but i might be worth moving that.
i would try just setting model.value to a fixed string and see if that gets set?
For more complex stuff you can subscribe to the formSubmitting event inside your controller, and set values then but you really shouldn't need to do that for something this simple. e.g.
Thanks Kevin!
Finally figured it out. My code was setting $scope.model.value, but at the same time it was resetting the model object and removing other model fields and apparently it broke something in the Umbraco workflow.
Also worth noting that it doesn't support 'controller as' syntax.
Zakhar
This is a long shot but I am spending far too many hours trying to get a simple custom dropdown to work.
Mine won't save values either - can you post your final controller/view/package,manifest so I can try yours?
Thanks!
is working on a reply...