Custom Fields
What it is
Custom fields makes it possible to extend an IssueTrackerProduct instance with additional fields that are associated with the issue. If there's a particular field that only you and your organisation needs this is the way to do it. For example, you need to enter a "Machine Number" with every issue.
The custom fields you add continue to work once the issue is submitted so you can change it once submitted just like you can change urgency or sections for example. What's really nice is that you can filter on these custom fields too. For example, you have a custom field drop-down called "Office site" and you can filter issues by "London office", "Stockholm office", etc.
Adding a custom field is really easy and doesn't require any programming skills but to be honest, adding a more advanced custom field does require some programming skills. You might need to understand the Python variable types, jQuery Javascript, TALES expressions and Python scripts. At least, if you know what you're doing, everything is possible.
How to use it
Use the Zope Management Interface to create a Issue Tracker Custom Field. Once added, it will create the custom field
inside a Issue Tracker Custom Field Folder called custom_fields which is ordered so you can control
the order of how custom fields are displayed. If you move the custom_fields folder out and put it in the IssueTrackerProduct
instance's parent directory you can use the same custom fields for multiple instances. Nifty!
When you add a custom field the two most important questions (apart from Id and Title) is "Input type" and "Python type".
The "Input type" decides what type of widget will be used and the "Python type" decides what type of data will be saved.
Depending on the "Python type" you get some fundamental validation out-of-the-box. For example, you can't enter Blablabla into a custom
field whose "Python type" is int.
On the "Manage" tab for the custom field you get a form to put together your custom field. You can also preview (at the bottom of the page)
what it will look like as HTML. If you want to have special CSS or Javascript for the custom field you can enter that too. If you prefer to
code your CSS or Javascript as a separate object just create it as a Zope File or DTML Document and enter the path
(as a Zope object) to it. See the screenshots for examples.
You can add as many extra attributes as you like to your widget tag. The "Manage" page offers a few examples such as style,
size, onfocus, etc. but you can also specify your own arbitrary attribute keys.
Advanced configuration
Two of the most advanced configuration options is the "Visibility" option and the other tab "Validation". In these fields you enter
TALES expressions (Template Attribute Language Expression Syntax).
These usually start with python:... but basically allow anything that a TALES expression does. For example, if you want a custom
field to only appear if you have ?show_order_number=1 in the URL, set this for "Visibility":
python:bool(request.get('show_order_number'))
When you add "Validators", again you enter TALES expressions there. The extra namespace variable you have access to is value
so for example you can write this validation expression:
python:len(value.replace(' ','')) < 4
Lastly, if you chose select, checkbox or radio as "Input type" you need to have options to chose
from. This is done either by entering a TALES expression that returns a list (note: in the TALES expression you have access to context
so you can fetch lists from other Zope objects) or by typing them one by one down the list. When you write down the options manually, if you
want to separate value from caption you can use a | pipe character. Like this for example:
ax146 | Screwdriver long handle 146 yk225 | Hammer titanium 10mm me101 | Allan key small
Limitations
The obvious limitation is that you don't have a full programming language behind you for dynamically generating the widget. You're limited by what you can configure in the Zope management interface. Albeit plenty of options but, for example, you can't write regular expressions for validation or do advanced business logic for generating a default value. A lot of these things can be achieved by using Javascript and the loaded jQuery stack. With that you can write AJAX methods that talk to a server or for example if you want to just have todays date pre-filled as the default value.
But please, learn to live with it. Chose your fields such that you don't depend on too advanced features and you'll find that there's nothing stopping you from making custom fields really useful for you.