Copied to clipboard

Flag this post as spam?

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


  • ced 16 posts 136 karma points
    Jan 22, 2020 @ 09:24
    ced
    0

    Extend property editor stores value with [\r\n \"value\" \r\n]

    Hello Umbraco community

    I'm having some trouble with a custom property editor we made. The idea was to extend the default checkboxlist property editor to have its items translated.

    Here is the package.manifest

    {
      "propertyEditors": [
        {
          "alias": "Wavenet.TranslatedCheckboxList",
          "name": "Translated Checkbox List",
          "isParameterEditor": true,
          "editor": {
            "view": "~/App_Plugins/TranslatedCheckboxList/Views/TranslatedCheckboxList.html",
            "valueType": "STRING"
          },
          "prevalues": {
            "fields": [
              {
                "label": "Add checkbox item",
                "description": "add an item to the checkbox list",
                "key": "viewItems",
                "view": "~/Umbraco/Views/PrevalueEditors/MultiValues.html"
              }
            ]
          }
        }
      ],
      "javascript": [
        "~/App_Plugins/TranslatedCheckboxList/TranslatedCheckboxList.controller.js"
      ]
    }
    

    In backoffice everything is working well. I can check values, save, edit another document, come back and my values are still there.

    The problem comes in a View when I want to get the values stored by the custom checkbox list (by doing a Content.Value<>

    I took a look in the database and it confirmed what I though (see the screenshot)

    enter image description here

    I took a look on how the values where stored by the default umbraco checkboxlist and there is no "\r\n" added (see the screenshot)

    enter image description here

    So.... Am I missing something?

  • Nik 1593 posts 7151 karma points MVP 6x c-trib
    Jan 22, 2020 @ 09:27
    Nik
    0

    Hi ced,

    \r\n doesn't show in SQL I don't think. Instead it shows as large amounts of white space. I suspect if you were to copy the value and paste it into a text editor you'd see newlines in it.

    Nik

  • ced 16 posts 136 karma points
    Jan 22, 2020 @ 09:44
    ced
    0

    That's the point Nik.

    My question is why the default Umbraco CheckboxList property editor stores the values correctly in db and my custom editor is not (and adding "\r\n") ? Because as you see in the package.manifest I use the same View ("~/Umbraco/Views/PrevalueEditors/MultiValues.html") for editing as the default one.

  • ced 16 posts 136 karma points
    Jan 28, 2020 @ 16:09
    ced
    100

    Just for everybody knows. I don't still get how the problem is currently happening. As I don't have time to debug, I just switch "valueType" of the "editor" to JSON and it's working like it should.

          "editor": {
             "view": "~/App_Plugins/TranslatedCheckboxList/Views/TranslatedCheckboxList.html",
             "valueType": "STRING"
          }
    

    Thanks to let me know if someone find a solution with "STRING"

Please Sign in or register to post replies

Write your reply to:

Draft