Defect #844
closedCustom fields helper uses local- instead of instance custom_value variable
0%
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
Updated by Jean-Philippe Lang over 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.
Updated by Christian Bryn over 16 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 :--)