官术网_书友最值得收藏!

Removing the none option

Custom field types such as select list (single and multi) come with the None option, and the only way to remove that is to make the field required. While this makes sense, it can be cumbersome to chase down every field and configuration.

In this recipe, we will remove the None option from all single select list custom fields.

Getting ready

Since we will be modifying physical files in JIRA, you will want to make backups of the files we change.

How to do it…

JIRA uses Velocity templates to render custom fields. These templates are mostly HTML with some special symbols. You can find all these files in the JIRA_INSTALL/atlassian-jira/WEB-INF/classes/plugins/fields directory, and the edit view templates are in the edit subdirectory.

So we need to open the edit-select.vm file in a text editor and remove the following code snippet:

#if (!$fieldLayoutItem || $fieldLayoutItem.required == false)
        <option value="-1">$i18n.getText("common.words.none")</option>
    #else
        #if ( !$configs.default )
        <option value="">$i18n.getText("common.words.none")</option>
        #end
    #end

Make sure you do not change any other lines, then save the file, and restart JIRA.

Tip

You can remove the None option from other custom field types, such as multi-select by editing the appropriate file, for example, edit-multiselect.vm.

How it works…

The Velocity .vm template files are what JIRA uses to render the HTML for the custom fields. The code snippet we removed is what displays the None option. Note that by changing the template, we are removing the None option for all single select custom fields in JIRA. If you just want to remove the None option for a single custom field, refer to the Using JavaScript with custom fields recipe.

主站蜘蛛池模板: 诏安县| 霍邱县| 龙游县| 达孜县| 阳春市| 通许县| 嫩江县| 哈巴河县| 武隆县| 乳山市| 乌兰浩特市| 招远市| 调兵山市| 阿克陶县| 厦门市| 河北省| 三都| 得荣县| 灯塔市| 高州市| 张北县| 阳东县| 沐川县| 盐池县| 方正县| 宣威市| 镇安县| 清水县| 五家渠市| 桃园市| 西乌| 新安县| 昌乐县| 密山市| 平山县| 简阳市| 绥阳县| 枣庄市| 晋中市| 广平县| 韩城市|