Top Menu

Jump to content
Home
    • Projects
    • Work packages
    • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Professional support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?
      Create a new account

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
  • Roadmap
  • Work packages
  • Calendars
  • Team planners
  • Boards
  • Forums
  • Wiki
    • Table of contents
      • Expanded. Click to collapseCollapsed. Click to showDeveloper
        • Hierarchy leafAccessibility Checklist
        • Hierarchy leafCode Review Guidelines
        • Expanded. Click to collapseCollapsed. Click to showContribution
          • Hierarchy leafGit Workflow
          • Hierarchy leafTranslations
        • Expanded. Click to collapseCollapsed. Click to showDeveloping Plugins
          • Hierarchy leafDeveloping an OmniAuth Authentication Plugin
        • Hierarchy leafRelease Process
        • Hierarchy leafReport a bug
        • Hierarchy leafSecurity
        • Hierarchy leafSetting up an OpenLDAP server for testing
        • Hierarchy leafTheme Features
      • Hierarchy leafDownload
      • Expanded. Click to collapseCollapsed. Click to showFeature tour
        • Hierarchy leafRelease Notes OpenProject 30
        • Expanded. Click to collapseCollapsed. Click to showRelease Notes OpenProject 30 - Overview
          • Hierarchy leafGlossary
          • Hierarchy leafRelease Notes - Accessibility
          • Hierarchy leafRelease Notes - Accessibility changes
          • Hierarchy leafRelease Notes - Add work package queries as menu items to sidebar
          • Hierarchy leafRelease Notes - Copy projects based on Templates
          • Hierarchy leafRelease Notes - Design changes
          • Hierarchy leafRelease Notes - Fixed Bugs
          • Hierarchy leafRelease Notes - Keyboard Shortcuts
          • Hierarchy leafRelease Notes - Project settings
          • Hierarchy leafRelease Notes - Ruby&Rails Update
          • Hierarchy leafRelease Notes - Security
          • Hierarchy leafRelease Notes - Timelines
          • Hierarchy leafRelease Notes - Work packages
      • Hierarchy leafHowto create animated gifs
      • Hierarchy leafMigration Squashing
      • Hierarchy leafMod security
      • Hierarchy leafNew work package page
      • Hierarchy leafOP3 to OP4 Debian upgrade
      • Hierarchy leafOP4 Ubuntu1404 Stable with MySQL in production
      • Hierarchy leafOpenProject 40 Development Setup
      • Expanded. Click to collapseCollapsed. Click to showOpenProject Foundation
        • Hierarchy leafBoards
        • Hierarchy leafMembers
        • Hierarchy leafOPF-Meetings
        • Hierarchy leafStatutes
      • Expanded. Click to collapseCollapsed. Click to showRelease Notes
        • Hierarchy leafOpenProject released on Bitnami
      • Expanded. Click to collapseCollapsed. Click to showRelease Notes OpenProject 40 - Overview
        • Hierarchy leafRelease Notes OpenProject 40 - Accessibility improvements
        • Hierarchy leafRelease Notes OpenProject 40 - Column header functions in work package table
        • Hierarchy leafRelease Notes OpenProject 40 - Improved Design
        • Hierarchy leafRelease Notes OpenProject 40 - Integrated query title on work package page
        • Hierarchy leafRelease Notes OpenProject 40 - Integrated toolbar on work package page
        • Hierarchy leafRelease Notes OpenProject 40 - OmniAuth integration for OpenProject
        • Hierarchy leafRelease Notes OpenProject 40 - Work package details pane
      • Expanded. Click to collapseCollapsed. Click to showSecurity and privacy
        • Hierarchy leafFAQ
      • Expanded. Click to collapseCollapsed. Click to showSupport
        • Expanded. Click to collapseCollapsed. Click to showDownload and Installation
          • Hierarchy leafInstallation MacOS
          • Expanded. Click to collapseCollapsed. Click to showInstallation OpenProject 3 0
            • Hierarchy leafDebian Stable with MySQL in production
            • Hierarchy leafInstallation Ubuntu
            • Hierarchy leafInstallation Windows
            • Hierarchy leafInstallation on Centos 65 x64 with Apache and PostgreSQL 93
          • Expanded. Click to collapseCollapsed. Click to showInstallation OpenProject 40
            • Hierarchy leafOP4 Debian Stable with MySQL in production
          • Expanded. Click to collapseCollapsed. Click to showMigration paths
            • Hierarchy leafFrom Chilliproject to OpenProject
            • Hierarchy leafMigration 15 to 30
            • Hierarchy leafMigration 24 to 30
            • Hierarchy leafMigration Redmine 2x › OpenProject 30
            • Hierarchy leafOpenProject 3 Migration
          • Hierarchy leafOpenProject 40
        • Expanded. Click to collapseCollapsed. Click to showNews
          • Hierarchy leafNew OpenProject Translations Plugin
          • Hierarchy leafNew Plugin on OpenProjectorg Local Avatars
          • Hierarchy leafNew design for OpenProject
          • Hierarchy leafNews Accessibility workshop for OpenProject
          • Hierarchy leafNews Glossary for OpenProject
          • Hierarchy leafNews Heartbleed fixed
          • Hierarchy leafNews Icon Fonts
          • Hierarchy leafNews OpenProject 30 Release
          • Hierarchy leafNews Release GitHub Integration Plugin
          • Hierarchy leafNews Success Story Deutsche Telekom
          • Hierarchy leafNews Timelines
          • Hierarchy leafOpenProject 3013 released
          • Hierarchy leafOpenProject 3017 released
          • Hierarchy leafOpenProject 40 released
          • Hierarchy leafOpenProject 40 will be coming soon
          • Hierarchy leafOpenProject 405 released
          • Hierarchy leafOpenProject and pkgrio
          • Hierarchy leafOpenProject news moved to a new blog
          • Hierarchy leafOpenProjectBitnami
          • Hierarchy leafPackager version with plugins released ("Community edition")
          • Hierarchy leafRegistration OpenProject-Foundation
          • Hierarchy leafRelease OpenProject AuthPlugins
          • Hierarchy leafUpdates on OpenProject
          • Hierarchy leafWe need your feedback for the the new fullscreen view for work packages
        • Hierarchy leafOpenProject Plug-Ins
      • Hierarchy leafWiki
You are here:
  • Forums
  • Development

Content

Bug Fix on Custom Fields

Added by jason southwell almost 9 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)

RE: Bug Fix on Custom Fields - Added by Jens Ulferts almost 9 years ago

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

RE: Bug Fix on Custom Fields - Added by jason southwell almost 9 years ago

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:

<select id="work_package_custom_field_values_10" name="work_package[custom_field_values][10]">&lt;option value="High"&gt'High&lt;/option&gt;%lt;option value="Low"&gt;Low&lt;/option&gt;</select>

RE: Bug Fix on Custom Fields - Added by Jens Ulferts almost 9 years ago

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:

when "list" 
      blank_option = custom_field.is_required? ?
                       (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>".html_safe : ''.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)

or to have less html_safe in there:

when "list" 
      blank_option = custom_field.is_required? ?
                       (custom_field.default_value.blank? ? "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>" : '') :
                       '<option></option>'

      select_tag(field_name, blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value), :id => field_id)

which after some refactoring could be this:

      blank_option = if custom_field.is_required? && custom_field.default_value.blank?
                       "<option value=\"\">--- #{l(:actionview_instancetag_blank_option)} ---</option>"
                     elsif custom_field.is_required? && !custom_field.default_value.blank?
                       ''
                     else
                       '<option></option>'
                     end

      options = blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized), custom_value.value)

      select_tag(field_name, options, :id => field_id)

I opened up a bug for that:

Care to provide a pull request for that? I wouldn’t want to steal your work.

RE: Bug Fix on Custom Fields - Added by jason southwell almost 9 years ago

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?

RE: Bug Fix on Custom Fields - Added by Birthe Lindenthal almost 9 years ago

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

RE: Bug Fix on Custom Fields - Added by Philipp Tessenow almost 9 years ago

Just out of curiosity: Birthe, why don’t we upload that agreement and link to it instead of sending a mail to everyone?

RE: Bug Fix on Custom Fields - Added by Birthe Lindenthal almost 9 years ago

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.

RE: Bug Fix on Custom Fields - Added by Jens Ulferts almost 9 years ago

Issued a PR, so that should be fixed soon. Thanks again.

RE: Bug Fix on Custom Fields - Added by Jens Ulferts almost 9 years ago

The PR got merged, so it is now part of the dev branch.

  • (1 - 9/9)
Loading...