Hide Fields Based on dropdown value in Magnolia content app

给你一囗甜甜゛ 提交于 2019-12-01 10:20:40

问题


I am developing a content app similar to Tours. In this I have a form that has multiple fields. Now i have a requirement like http://jsfiddle.net/5SArB/1911/ fiddle. I need to hide few fields based on the selection from dropdown like how parent details hidden when age is more than 18 . How to achieve this in magnolia content app?enter code here


回答1:


This should be your yaml in Magnolia 5.7.

You should use the switchable field combined with composite field:

wide: true
form:
  tabs:
    - name: tabForm
      label: Form registration
      fields:
        - name: username
          label: Name
          fieldType: text
        - name: email
          label: Email
          fieldType: text
        - name: ageConfig
          fieldType: switchable
          label: Age
          selectionType: select
          transformerClass: info.magnolia.ui.form.field.transformer.composite.DelegatingCompositeFieldTransformer
          type: String
          options:
            - name: young
              label: 18 or younger
              value: young
            - name: old
              label: 19 or older
              value: old
          fields:
            - name: young
              fieldType: composite
              label: ''
              layout: vertical
              fields:
                - name: parentName
                  fieldType: text
                  label: Parent name
                - name: parentMail
                  fieldType: text
                  label: Parent email
            - name: old
              fieldType: hidden

actions: !include:/my-project/dialogs-common/actions-block.yaml

This is the "young" case:

This is the "old" case:




回答2:


You can do this by extending either SwitchableFieldFactory or CompositeFieldFactory and coding desired behaviour there.

HTH,
Jan



来源:https://stackoverflow.com/questions/32066415/hide-fields-based-on-dropdown-value-in-magnolia-content-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!