IssueTrackerProduct

A user friendly bug tracking web application for Zope

Set up custom fields to your issuetrackerSet up custom fields to your issuetracker

06 Jul 2008

We're not happy with the input fields that goes with every issue so we want to add some extra custom fields to collect the users details.

Version requirement:

Min. version: 0.10.1

What we're going to do now we're doing for just one issuetracker instance. If you want this to work for multiple issuetrackers, you can, and we'll show that later.

Add from drop-down Now go the instance and enter the Zope management interface (e.g. http://localhost:8080/tracker/manage) and from the drop-down select "Issue Tracker Custom Field". For the first screen enter the following:

Id nick-name
Title Nick name
Input type text
Python type ustring
Place in custom fields folder Yes!

The Manage tab On the following screen most of the options are rather self-explanatory. The interface has two main tabs: "Manage" and "Validation". On Manage you control how the input should present itself and you can also control surrounding Javascript and CSS.

The DOM ID of the input field will be prefix id_ followed by the ID of the custom field object itself, so in this first example the DOM ID will be "id_nick-name". That's important to know if you want to include some Javascript that refers to this element for example:

 $(function() {
    $('#id_nick-name').click(function() {
      $(this).addClass('clicked');
    });
 });

NB. This example uses jQuery.

Right. That was easy. Let's now add a slightly more complicated custom field: Age. Create it the same was as the Nick name field we added before and note that we expect to save a number but we don't select Python type int because then we'll have to always save an integer and would require us to make the field mandatory.

On the Manage tab for custom field age add an extra attribute with the drop-down. Select Size and enter the value 3 for it. Next we'll write some code that checks the input so that it's a reasonable input. Click the Validation tab.

Adding a validation expression Click to add a new validation expression plus message if the validation message doesn't return True. I know that this is a silly example but it shows the powerful options you have. The TALES expression is something all people familiar with Zope knows how to use. It's really simple to learn otherwise. Most of the time you just want to enter a Python expression and the variable value is available for you in this namespace. See the screenshot for the example you can use. You can enter multiple validation expressions. So for example you could add one that checks that the age is greater than 1 with one error message and another validation expression with a different message. Hopefully it's rather self-explanatory once you get going.

Lastly we'll add a radio button selection of gender. We'll present it such that the options are "Male" or "Female" but we'll save it as just "m" or "f". Go back and add a new "Issue Tracker Custom Field" but this time select "radio" as the Input type. These type of fields will have an extra property on the Manage tab: Options. The syntax is that you write each and every option line by line and to separate the label from the actual value you use a | pipe character like this:

 m| Male
 f| Female

All whitespace is filtered out automatically. If for example, this wasn't gender by something like "County" and instead of radio button you use a select input then you might want to use a dynamic list of options. If so, click the link "Enter an expression" and enter a valid TALES expression. Suppose we've created a Python Script in the Zope management interface called getCounties then enter this expression:

 here/getCounties

How you implement the Python Script is up to you but basically it should return a Python list.

End result The end result, when clicking on the Add Issue page, should look something like this screenshot. You can of course take this a lot further and there are more types of inputs you can use and there are more options for managing your custom fields. The best approach right now might be to play around a little bit with it and see what it can do for you.

As you might have noticed, by default it put all of these custom fields into a folder called custom_fields. That's a hardcoded name the Add Issue page is programmed to search for. This means, and this is a great thing, that since Zope support acquisition, you can move this folder up to a parent folder where by it can be reached by all IssueTrackerProduct instances. Or you can combine this with adding individual custom fields directly in the issuetracker instances. For example, you want the custom field "Employee ID" and "Department" on all your issuetrackers but in a particular issuetracker you also want an extra "Building no." field. That's possible too.

<<< Return to all how-tos