Project

General

Profile

Actions

Defect #844

closed

Custom fields helper uses local- instead of instance custom_value variable

Added by Christian Bryn about 16 years ago. Updated over 15 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
Custom fields
Target version:
-
Start date:
2008-03-12
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

Hi!

I realize this bug is a cause of my hacking attempt and thus not visible on a standard install, but here goes:

I was to rearrange fields, including 6 custom fields on the issue add/edit form (app/views/issues/_form.rhtml). I assumed I could refer to the specific fields using i.e.

<p><% custom_field_tag_with_label @custom_values[3] %></p>

...this works when adding new issues, but when editing an issue the custom fields loose their data/selected value. Saving the issue will save empty values (or scream about empty required fields ;-) )

Some debugging revealed what seems to be the problem: The custom_fields_tag function passes a local variable custom_value to the HTML-field functions (defined in the form_helper.rb), i.e. text_field, which takes instance variables. From api.rubyonrails.com:

text_field(:post, :title, :size => 20)
# => <input type="text" id="post_title" name="post[title]" size="20" value="#{@post.title}" />

...which is why I reckon it works when looping over the @custom_values, @custom_value is correct when the input field is being assigned its value.

I have attached a quick fix for custom_fields_helper.rb to make this work.
I found the bug in 0.6.3, but the behavior is the same in subversion.

Regards,
Christian Bryn


Files

custom_fields_helper.rb.diff (41 Bytes) custom_fields_helper.rb.diff Christian Bryn, 2008-03-12 23:14
Actions #1

Updated by Jean-Philippe Lang almost 16 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

This problem no longer applies to r1592.
CustomFieldsHelper#custom_field_tag uses *_tag (eg. text_field_tag) helpers instead. These helpers do not rely on instance variables.

Actions #2

Updated by Christian Bryn over 15 years ago

Jean-Philippe Lang wrote:

This problem no longer applies to r1592.
CustomFieldsHelper#custom_field_tag uses *_tag (eg. text_field_tag) helpers instead. These helpers do not rely on instance variables.

Great work, thanks!

- Christian :--)

Actions

Also available in: Atom PDF