Content
You are here:
Bug Fix on Custom Fields
Added by jason southwell over 10 years ago
In the 3 beta dev branch, the custom_fields_helper.rb file has a bug
the code:
when "list" blank_option = custom_field.is_required? ? (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>".html_safe : '') : '<option></option>'.html_safe select_tag(field_name, blank_option + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), :id => field_id)
should be:
when "list" blank_option = custom_field.is_required? ? (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>".html_safe : '') : '<option></option>'.html_safe select_tag(field_name, (blank_option + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value)).html_safe, :id => field_id)
This fixes the problem where the options in a list type Custom Field are rendered to the browser as a string rather than html Option tags.
Replies (9)
Hi Jason,
thanks for the hint.
As of yet I have been unable to find a screen which displays html tags for list custom fields where a drop down should be rendered.
Can you please point me to one?
Best
Jens
Sorry if I wasn’t clear. The problem wasn’t that html tags would be visibly displayed, but that the option tags were rendered as strings instead of option tags. Specifically where you see the problem is if you have a custom field for a work package that is of type list and you add many list items. Then when you go to create a new work package, the drop down is rendered but with no items. If you look at the source, the looks something like this:
Thanks for clarifying. Now I’ve got it. It took me some time because there is only a bug when the custom field has a non empty default value. So the html_safe is missing on the blank_option in those awfully nested ternary if statement:
or to have less html_safe in there:
which after some refactoring could be this:
I opened up a bug for that:
Care to provide a pull request for that? I wouldn’t want to steal your work.
The work is yours to steal.
On another note, there is a link to a contributor agreement for me to sign before I’m supposed to start contributing but it appears to not actually exist. Is there an agreement that you want signed or should we just start contributing as we see fit?
Hi Jason,
yes, in deed, there is a Contributor Agreement to clarifiy your rights to use your own contributions. I will send it to you via email.
Cheers,
Birthe
Just out of curiosity: Birthe, why don’t we upload that agreement and link to it instead of sending a mail to everyone?
We can do so as well. I was just waiting for http://development.contributoragreements.org/ to finish their individual CLA. However, it seems that it’s better to publish our own version.
Issued a PR, so that should be fixed soon. Thanks again.
The PR got merged, so it is now part of the dev branch.