[DOCU-2042] Switchable Field: Clarify the references between the option-group and the form Created: 10/Aug/20  Updated: 20/Oct/21  Resolved: 20/Oct/21

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Christian Ringele Assignee: Ashraf Khamis
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Situation:

Problem:

  • Example code of the docu uses only foo and bar everywhere:
switchable:
  $type: switchableField
  field:
    $type: radioButtonGroupField
    datasource:
      $type: optionListDatasource
      options:
        - name: foo
          value: foo
        - name: bar
          value: bar
  itemProvider:
    $type: jcrChildNodeProvider
  forms:
    - name: foo
      properties:
        foo:
          $type: textField
    - name: bar
      properties:
        bar:
          $type: richTextField
  • When adding real fields I stumbled over what in the 'options' references what in the 'forms'. Took me some time to figure it out.
  • It is not intuitive! My first guesses were all wrong!
    This code works/is the solution:
    switchable:
      $type: switchableField
      label: Test Switchable
      field:
        $type: radioButtonGroupField
        datasource:
          $type: optionListDatasource
          options:
            - name: whatever1
              value: foo
              label: Foo
            - name: whatever2
              value: bar
              label: Bar
      itemProvider:
        $type: jcrChildNodeProvider
      forms:
        - name: foo
          properties:
            whatever3:
              $type: textField
              label: Foo
        - name: bar
          properties:
            whatever4:
              $type: richTextField
              label: Bar
  • see the : whatever1-4 -> they are all ignored/not relevant!
  • So what references what:
    • the form's name references the options value!


 Comments   
Comment by Roman Kovařík [ 20/Oct/21 ]

So the description could be just: option names of switchable field are ignored, just the option value is relevant.
Technically, I can't see anything wrong with that, in radioButtonField, only the value is relevant/used/persisted, the name is used just to generate i18n keys.
Also in the docu example, the name and value are the same, which is a good practise.

Comment by Ashraf Khamis [ 20/Oct/21 ]

Closing the ticket as Won't Do. See Roman's comment above.

Generated at Mon Feb 12 01:23:32 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.