wiki:TracTicketChainedFieldsPlugin

Dynamically change field depending on value of parent

Description

This plugin allows you to dynamically change fields options by their parent fields.

For example, there are 3 fields: brand, phone, OS. When the phone brand changes, the phone field will change its options to show only the phone that belongs to that brand. When the phone changes, the OS field will change accordingly.

  1. Add 3 custom fields in your trac.ini file:
    [ticket-custom]
    tcf_brand = text
    tcf_brand.label = Brand
    tcf_brand.order = 3
    tcf_phone = text
    tcf_phone.label = Phone
    tcf_phone.order = 4
    tcf_os = text
    tcf_os.label = OS
    tcf_os.order = 5
    
  2. Go to Admin -> Chained Fields, edit the configuration:
    {
        "tcf_brand": {
            "Nokia": {
                "tcf_phone":{
                    "5800": {
                        "tcf_os":{
                            "Symbian": {},
                            "Android": {}
                        }
                    }
                }
            },
            "SE": {
                "tcf_phone":{
                    "": {
                        "tcf_os":{
                            "": {}
                        }
                    }
                }
            },
            "Apple": {
                "tcf_phone":{
                    "iPhone": {
                        "tcf_os":{
                            "OS X": {},
                            "OS": {}
                        }
                    },
                    "iPhone 3G": {
                        "tcf_os":{
                            "OS X": {},
                            "other": {}
                        }
                    }
                }
            }
        }
    }
    

Notes:

  • If there are no options for some fields, like "SE" above, you still need to supply the full structure, with empty string as keys.
  • It supports any fields after [7793].

The list of applicable phones changes based on the selections made in the Brand and OS fields:

See also KeepInterfaceSimplePlugin, which contains similar (and additional) functionality.

Bugs/Feature Requests

Existing bugs and feature requests for TracTicketChainedFieldsPlugin are here.

If you have any issues, create a new ticket.

defect

11 / 17

enhancement

3 / 6

task

1 / 1

Download

Download the zipped source from here.

Source

You can check out TracTicketChainedFieldsPlugin from here using Subversion, or browse the source with Trac.

Installation

General instructions on installing Trac plugins can be found on the TracPlugins page.

Simplejson is a requirement for Python < 2.6, and it should be installed automatically if required when running easy_install.

  1. Uninstall TracTicketTemplate if you have it installed before.
  2. Change to the directory containing setup.py.
  3. If you want to install this plugin globally, this will install this plugin to the Python path:
    python setup.py install
    
  4. If you want to install this plugin to the Trac instance only:
    • python setup.py bdist_egg
    • copy the generated egg file to the trac instance's plugin directory:
      cp dist/*.egg /srv/trac/env/plugins
      
  5. Add the follwing line to the components section of the trac.ini file:
    [components]
    tcf.* = enabled
    
    [tcf]
    hide_empty_fields = false
    chained_fields = tcf_brand, tcf_phone, tcf_os
    
    or:
    chained_fields = component, tcf_brand, tcf_phone, tcf_os
    
    for non-tcf_ starting fields.

hide_empty_fields is the option which enable "hide fields when there are no supplied options", default is false. See #5638 for more details.

Recent Changes

18444 by rjollos on 2021-09-28 18:53:49
1.2dev: Remove TCF_ADMIN

Require TICKET_ADMIN to access admin panel.

Refs #14050.

17325 by rjollos on 2019-01-03 17:13:57
0.2: Release version 0.2
17324 by rjollos on 2019-01-03 17:13:21
0.2dev: Remove tag_svn_revision attribute
(more)

Author/Contributors

Author: richard
Maintainer: Richard Liao
Contributors:

Last modified 7 years ago Last modified on Mar 28, 2018, 3:50:48 PM

Attachments (1)

Download all attachments as: .zip