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)
Community moderators have prevented the ability to post new answers.
Override validateFromParams method and do nothing there. See if it helps.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Not sure if it is changed in the later versions but it used to work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What do you mean by remove option values? I'm a little confused.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Glad it worked. I was confused why it didn't work!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.