Copied to clipboard

Flag this post as spam?

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


  • Tim C 161 posts 528 karma points
    May 13, 2016 @ 14:29
    Tim C
    0

    Custom Property Editor Dropdown not saving selected value

    I have been trying to build a custom property editor based on the dropdown.

    I have managed to get it to build with a set of options based on a prevalues field, and when I edit the document with this editor, I see all the drop down options, but having selected one and saved the document, it does not save my selection. (I checked the back end db, and no value is being written)

    I must be missing something?

    code extracts...

    package.manifest

    ...

    prevalues:{
                fields:[
                    {
                        label:"Options",
                        description: "Options",
                        key:"myOptions",
                        view:"multivalues"
                    },
    

    ...

    view

     <select  ng-model="model.value" ng-options="opt.id as opt.value for opt in model.config.myOptions">
             <option></option>
     </select>
    

    Do I need to somehow bind them to the model?

    ps just tested, if I hard code the options in the view it works fine. Hmm.....what do I do next!

    UPDATE

    Just can't fix this. I have noticed as soon as I save a document having selected an option, it reverts to none selected, so it must be something to do with the binding.

    HELP!

  • Marc Goodson 2149 posts 14377 karma points MVP 9x c-trib
    May 15, 2016 @ 09:18
    Marc Goodson
    100

    Hi Tim

    If you loop through you config options

     <li ng-repeat="option in model.config.myOptions">
                <span><a ng-click="logOption(option)">{{option.Id}} - {{option.value}} </a></span>
            </li>
    

    You'll see there is no id property stored for them in the model.config.myOptions...

    and so your model.value never gets set to anything, and it appears not to be saving !!

    so if you tweak your loop to be:

    <select ng-model="model.value" ng-options="opt.value as opt.value for opt in model.config.myOptions">  
    </select>
    

    Then the options in the dropdown should save as the model.value for the property, and when you revisit the page, the dropdown value will be set to the saved value...

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft