How to call and display a custom value of an issue ?
Added by Alice Etchegaray almost 11 years ago
Hi,
My question is in the title : how to call and display a custom value of an issue ?
Is there a function to do that ?
Thank for your help,
Alice.
Replies (4)
RE: How to call and display a custom value of an issue ?
-
Added by Martin Denizet (redmine.org team member) almost 11 years ago
Hello Alice,
As far as I remember, it is:
<%= issue.custom_field_values[field_id] %>
Where
field_id
is the id of the custom field.Cheers,
RE: How to call and display a custom value of an issue ?
-
Added by Alice Etchegaray almost 11 years ago
Thank for your reply Martin.
But the value of field_id isn't corresponding to the id of the custom field...
In fact, I would automatize this field : I would get back the value of the custom field where the custom_field_id = 2 and the customized_id = issue.id.
Do you understand ?
Here is my code :
<table class="list related-issues"> <caption><%= l(:label_related_issues) %></caption> <%- @issues.each do |issue| -%> <tr class="issue hascontextmenu"> <td class="checkbox"><%= check_box_tag 'ids[]', issue.id, false, :id => nil %></td> <td class="subject"><%= link_to_issue(issue, :project => (@project != issue.project)) %></td> <td>Etape : </td> <td class="etape"><%= issue.custom_field_values[{:custom_field_id => 2, :customized_id => :issue.id}] %></td> </tr> <% end %> </table>
RE: How to call and display a custom value of an issue ?
-
Added by Martin Denizet (redmine.org team member) almost 11 years ago
I had to go to check and the correct method is:
issue.custom_field_value(field_id)
So in your case:
<td class="etape"><%= issue.custom_field_value(2) %></td>
The method declaration for more details: https://github.com/redmine/redmine/blob/master/lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
Cheers,
RE: How to call and display a custom value of an issue ?
-
Added by Alice Etchegaray almost 11 years ago
Ok, it's working :)
Thank you Martin !