[MGNLUI-6860] Switchable ignores SubForm Layout Definition Created: 03/Sep/21  Updated: 09/May/23

Status: Open
Project: Magnolia UI
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Alexander Hems Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2021-09-03-16-10-17-909.png    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: FieldsMaintenance
Team: Nucleus

 Description   

Steps to reproduce

  1. Define in sub-forms something like :
switchable:
  $type: switchableField
  field:
    $type: radioButtonGroupField
    layout: horizontal
    defaultValue: option1
    datasource:
      $type: optionListDatasource
      options:
        - name: option1
          value: option1
          label: option1
        - name: option2
          value: option2
          label: option2
  itemProvider:
    $type: currentItemProvider
  forms:
    - name: option1
      layout:
        $type: horizontal
      properties:
        option1field1:
          $type: textField
          label: option1field1
        option1field2:
          $type: textField
          label: option1field2
    - name: option2
      layout:
        $type: tabbedLayout
        tabs:
          tab1:
            fields:
              - name: option2field1
          tab2:
            fields:
              - name: option2field2
      properties:
        option2field1:
          $type: textField
          label: option2field1
        option2field2:
          $type: textField
          label: option2field2
  1. Open Dialog
  2. Forms are always Vertical

Expected results

I would expect the form definition to be used as described in your own documentation.
Because you refer in the switchable documentation directly to the form definition →
https://docs.magnolia-cms.com/product-docs/6.2/Templating/Dialog-definition/Field-definition/List-of-fields/Switchable-field.html 
https://docs.magnolia-cms.com/product-docs/6.2/Templating/Dialog-definition/Form-definition.html#_layout_types 

Actual results

It is always a vertical layout, no matter what I define in the YAML.

Workaround

As a Workaround to add more flexibility to the forms, we add a custom SwitchableFieldDefinition and a Clone of the SwitchableFormView.
There we use the sub-form defined layout if it's not the default SingleTabLayoutProducer

Development notes


Generated at Mon Feb 12 09:40:44 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.