Copied to clipboard

Flag this post as spam?

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


  • Krzysztof 1 post 71 karma points
    Feb 23, 2021 @ 21:46
    Krzysztof
    0

    Umbraco toggle configuratin values stored in database differently depending on how datatype was created

    Does anyone know why toggle values are stored differently in umbracoDataType table depending on how datatype was created?

    When I create new datatype using toggle property editor "Initial State" and "Show toggle labels" config values are stored as true/false: View of umbracoDataType table row for toggle property editor data type But when I create custom property editor with boolean prevalues (part of package manifest below):

    "prevalues": {
        "fields": [
          {
            "label": "Key auto generated",
            "description": "If checked then key will be auto generated as camel case value",
            "hideLabel": false,
            "key": "keyAutoGenerated",
            "view": "boolean"
          }
        ]
      }
    

    Then datatype created using this propery editor saves boolean values as 0/1 : View of umbracoDataType table row for custom property editor data type

    I came across this because I have custom plugin that allows to create toggle definition. This definition saves configuration with 0/1 values instead of true/false. It creates problems with showing toggle labels - button is generated with show-labels="1" configuration (as saved in database), and Angular condition for showing labels is:

    <!-- ngIf: !labelPosition && showLabels === 'true' || labelPosition === 'left' && showLabels === 'true' -->
    

    This kind of issue wasn't present in v7, because boolean property editor had slighty different definition for show labels config (Umbraco\Views\propertyeditors\boolean\boolean.html): v8:

            show-labels="{{model.config.showLabels }}"
    

    v7:

            show-labels="{{model.config.labelOn ? 'true': 'false'}}"
    

    I don't want to create bug report yet, as I'm not sure if it was intendend change or not. But to be honest getting back to v7 solution would make it less prone to issues caused by different storing format of boolean values in database ;)

Please Sign in or register to post replies

Write your reply to:

Draft