Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    CanvasItem default value

    I've created a custom form item using CanvasItem. If I give it a defaultValue, how can I make sure that a call to the form's getValues() already includes that item's default value?

    #2
    We're not really clear on the question. Please see the CanvasItem docs. If shouldSaveValue is set, and if you set a defaultValue, you should expect a showValue() call on initialization. There is nothing that you need to do to cause the value to be included in getValues().

    Comment


      #3
      I try to explain briefly:

      I've created a MenuButton as CanvasItem (like the "Font" en "Size" dropdowns in this editor). It's menu contains one embedded component, being a DynamicForm with several check boxes. The menu button itself has name "others". Using "shouldSaveValue" causes a nested value like "others": { "check1": false, "check2": true }.

      Maybe this approach is not the best, so any ideas are appreciated.

      Comment


        #4
        Basically, the problem I'm facing is a filter form with very limited horizontal space. I want to show the most prominent filters as separate fields and the check boxes in a drop down (or something similar). All fields should merge their values as one JSON object (without nested attributes).

        Comment


          #5
          OK, so the CanvasItem APIs work for this and one of the two CanvasItem samples in fact features a whole nested grid that produces a multiple value.

          Comment


            #6
            I'll try something else, using shouldSaveValue sets the initial value, but as nested attribute. Thus the CanvasItem is named "others", with its "defaultValue" set to { "check1": false, "check2": true }. This is not what I want, but never mind.

            Comment

            Working...
            X