Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

CF Plugin: Problem when creating Issue

Viktor Mirzoyan
Contributor
July 10, 2011

I've created a multiselect custom field type in which I populate my own "options". Although, my options show, when a user clicks Create, an error message is displayed:

Invalid value 'Hello 1' passed for customfield 'test'. Allowed values are: []

Code:

@Override

public Map getVelocityParameters(Issue issue, CustomField field, FieldLayoutItem fieldLayoutItem)

{

Map params = super.getVelocityParameters(issue, field, fieldLayoutItem);

List optList = new ArrayList();

optList.add("Hello 1");

optList.add("Hello 2");

params.put("options", optList);

return params;

}

Velocity template:

#customControlHeader ($action $customField.id $customField.name $fieldLayoutItem.required $displayParameters $auiparams)

#if ($value)

#set ($selectedValues = $value)

#end

<select class="select" id="$customField.id" multiple="multiple" name="$customField.id" size="5">

#if ($fieldLayoutItem && $fieldLayoutItem.required == false)

<option value="-1"#if (!$selectedValues || $selectedValues.empty || $selectedValues.contains("-1")) selected="selected"#end>${i18n.getText('common.words.none')}</option>

#end

#foreach ($item in $options)

<option#if ($selectedValues && $selectedValues.contains($item)) selected="selected"#end value="$textutils.htmlEncode($item)">

$item

</option>

#end

</select>

#customControlFooter ($action $customField.id $fieldLayoutItem.fieldDescription $displayParameters $auiparams)

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2011

Override validateFromParams method and do nothing there. See if it helps.

0 votes
Viktor Mirzoyan
Contributor
July 10, 2011

Didn't seem to do anything. I saw a previous post from someone who had this issue, and they also suggested overriding that method, but didn't specificy any details.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2011

Not sure if it is changed in the later versions but it used to work.

Viktor Mirzoyan
Contributor
July 10, 2011

What do you mean by remove option values? I'm a little confused.

Viktor Mirzoyan
Contributor
July 10, 2011

Scratch that. Good news, Jobin you were right, overriding validateFromParams worked.

Turns out my changes didnt go through when i tried it out the first time. Thanks!

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2011

As far as I know you need to have valid options. One approach I've taken is to remove option values, but whatever's left still need to be valid options.

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2011

Glad it worked. I was confused why it didn't work!

TAGS
AUG Leaders

Atlassian Community Events