Opened 4 years ago

Closed 4 years ago

# blank option is added when choosing [select-type] custom field

Reported by: Owned by: goyamashita@… rjollos normal BatchModifyPlugin normal batch modify blank select psuter 0.12

We have added a drop-down custom field. This field doesn't have blank option. When issuing or updating single ticket, we can't choose blank in this field.

To batch-modify this custom field, we selected this field in the batch modify section. Of course, field and drop-down are appeared in the batch modify section, but blank option is automatically added in the option and we can change it to blank.

This field is required field and don't want to change it to blank.

What should I do to erase blank option in the batch modify option?

Our environment:

• Trac Ver is 0.12
• Plugin Ver is 0.8

### comment:1 Changed 4 years ago by rjollos

• Description modified (diff)

### comment:2 Changed 4 years ago by rjollos

• Description modified (diff)
• Keywords changed from batch modify, blank, dropdown to batch modify blank dropdown
• Owner changed from CuriousCurmudgeon to rjollos
• Status changed from new to assigned

### comment:3 Changed 4 years ago by rjollos

I've investigated and found the following:

• In batchmod.js, we need to pass false for the third parameter to createSelect(name, options, optional), in order for the blank entry to not appear. This parameter is currently set to true.
• The determiner for the blank entry should be fields['custom'], which is returned by TicketSystem.get_ticket.fields. However, this is not currently passed to JavaScript.
• Some ticket fields, such as Component, have a similar problem. These fields have fields['optional'] = False, and setting the field to blank through the ticket form is not allowed, so presumably it shouldn't be allowed through BatchModify either.

Therefore, a fix for both issues would look something like this at line 55 of batchmod.js:

td.append(createSelect(inputName, property.options, true));


->

td.append(createSelect(inputName, property.options, property.optional || !property.custom));


property is populated from the properties array, which is instantiated in query.html, however this code was moved in later versions of Trac.

It seems like the fix here is to pass an array of optional and custom values and add them to the properties array. First though, I'm going to open an ticket in Trac since this plugin is included in the Trac core for version 1.0, and see what the Trac developers have to say about the issue.

### comment:4 follow-up: ↓ 5 Changed 4 years ago by goyamashita@…

• Resolution set to fixed
• Status changed from assigned to closed

From Questioner Thank you for your help rjollos, it worked out well.

### comment:5 in reply to: ↑ 4 Changed 4 years ago by rjollos

• Cc psuter added; anonymous removed
• Keywords select added; dropdown removed

From Questioner Thank you for your help rjollos, it worked out well.

Well, I didn't think that I had provided a solution. What did you find to be the solution in your case? I'm guessing that you just set optional = false. That might be a suitable workaround for your case, but of course it's not a general solution, since in some cases a blank option might be allowed (e.g. for Milestone).

I'm still considering to open a ticket in the Trac core about this, and I've cc'ed the developer who integrated the BatchModifyPlugin into the Trac core in case he has an opportunity to review and comment. Anyway I'll leave this ticket closed for now since the BatchModifyPlugin is not really maintained anymore.

### comment:6 Changed 2 years ago by rjollos

The issue was resolved on the Trac trunk in trac:#10772 for release 1.1.2.

Last edited 2 years ago by rjollos (previous) (diff)

### comment:7 Changed 2 years ago by rjollos

• Resolution changed from fixed to wontfix