# Ticket #2486 (new enhancement)

Opened 5 years ago

## Dynamic fields by ticket type

Reported by: Assigned to: steve@t220.com obs normal BlackMagicTicketTweaksPlugin normal CondFieldsPlugin 0.11

### Description

This would seem the logical place to implement the old 0.10 functionality of CondFieldsPlugin into 0.11 - i.e. dynamically showing and hiding fields based on the ticket type.

I realise that this functionality would be (partially) client-side, but it meshes well with the rest of the ideas here and would be a good next step.

The combination of restricting ticket-type changes by permissions and this would mean so much flexibility in implementations.

## Change History

### 01/28/08 17:16:24 changed by ixokai

• status changed from new to assigned.

I've been thinking about that; its something I need for work too.

However, I really don't want to do a lot of client-side javascript for essential functionality like that. The tooltips are one thing-- they're just informational.

I've been thinking of removing the 'Type' field from the form, and instead looking into the workflow internals to add a 'set_type' workflow action.

Basically, instead of changing the type and then having the rest of the fields be adjusted inline via javascript, you'd have to click on the bottom where it'd say "Set type to: <dropdown>" and submit. Then when it reloads it'd have the ticket changes in place.

### 01/28/08 23:08:45 changed by steve@t220.com

• keywords changed from ConfFieldsPlugin to CondFieldsPlugin.

I'm not sure my process gods would be happy with the extra step needed with your suggestion of workflow actions.

For my particular need it would be enough to allow the user to select a ticket type only on the new ticket page and then do as you suggest, but I was trying to keep the solution generic.

Would it be possible to allow fields to be shown only on ticket creation and hidden at all other times? Then just allow fields to be hidden conditional on ticket type and I'm sorted - no need for client-side JS. Even more evil for people not hiding ticket-type though.

Thanks for this plugin. I'm spending so much time generating our own dodgy workflow and plugins I'm not sure if I'll be able to contribute to this one...

### 02/04/08 17:33:42 changed by hoessler

Patch that adds conditional fields to the black magic plugin

### 02/04/08 17:36:14 changed by hoessler

This patch implements a basic solution to the above problem. It allows to hide fields depending on the ticket type. For example with this configuration

[blackmagic]
tweaks = cc


the cc field will only show up if the type of the ticket is set to "defect" or "task". For existing tickets, the current ticket type is taken. For new tickets, the type that is given as parameter to the page (e.g. via a /newticket?type=defect link) or, if none is given, the default type is used. If a user changes the type, he needs to submit this change before the corresponding conditional fields show up.

I've also moved the code some lines up that checks if fields need to be hidden so that "notice" or "tip" tweaks won't show up if fields are hidden.

Although this approach works for me, having an extra 'set_type' workflow action would probably be a nice thing.

### 07/19/08 14:34:03 changed by tocomo

hoesslers patch works great with trac 0.11. @ixokai: Why not integrate it into svn?

### 08/31/09 19:55:54 changed by rab1138

I found that the patch did not correctly pick up the ticket type in the request (Trac 0.11/Python 2.6 on Apache 2.2.1 /Ubuntu 9.0.4). Instead I always got the default ticket type for a new ticket request despite having, e.g. "/newticket?type=story".

I found that changing line 45 of blackmagic.py (post_patch) to read:

ticket_type = req.args.get('type')


resolved the problem.

Great new functionality with this patch!

### 09/12/09 00:58:26 changed by rab1138

As I've used this more, I've found that even when using links like "/newticket?type=defect", one still should not hide or disable the "type" selector. If you do, somehow the type will be used to render the form for creating the ticket, but won't propagate to the preview or submit (get the default ticket type). Still useful functionality; I just use a notice to warn users not to change the type.

### 11/27/09 09:15:20 changed by obs

• status changed from assigned to new.
• owner changed from ixokai to obs.

### 12/12/10 23:03:46 changed by robguttman

I just happened upon this old ticket but you all may be interested in the Dynamic Fields plugin which currently provides this (and other dynamic) functionality.

### Add/Change #2486 (Dynamic fields by ticket type)

Change Properties