# Show user's account
def show
@user = User.find_active(params[:id])
- @custom_values = @user.custom_values.find(:all, :include => :custom_field)
+ @custom_values = @user.custom_values
# show only public projects and private projects that the logged in user is also a member of
@memberships = @user.memberships.select do |membership|
# to move in project_custom_field
def self.for_all
- find(:all, :conditions => ["is_for_all=?", true])
+ find(:all, :conditions => ["is_for_all=?", true], :order => 'position')
end
def type_name
# Returns an array of all custom fields enabled for project issues
# (explictly associated custom fields and custom fields enabled for all projects)
def all_issue_custom_fields
- @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq
+ @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort
end
def project
</div>
<div style="clear:both;"> </div>
-<%= render :partial => 'form_custom_fields', :locals => {:values => @custom_values} %>
+<%= render :partial => 'form_custom_fields' %>
<% if @issue.new_record? %>
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
<div class="splitcontentleft">
-<% i = 1 %>
+<% i = 0 %>
<% split_on = @issue.custom_field_values.size / 2 %>
<% @issue.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :issue, value %></p>
assert_equal 2, issue.author_id
assert_equal 3, issue.tracker_id
assert_nil issue.estimated_hours
- v = issue.custom_values.find_by_custom_field_id(2)
+ v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2})
assert_not_nil v
assert_equal 'Value for field 2', v.value
end
return if self.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods)
cattr_accessor :customizable_options
self.customizable_options = options
- has_many :custom_values, :dependent => :delete_all, :as => :customized
+ has_many :custom_values, :as => :customized,
+ :include => :custom_field,
+ :order => "#{CustomField.table_name}.position",
+ :dependent => :delete_all
before_validation_on_create { |customized| customized.custom_field_values }
# Trigger validation only if custom values were changed
validates_associated :custom_values, :on => :update, :if => Proc.new { |customized| customized.custom_field_values_changed? }