Sha256: 7913cc1126fb9bc8b2bb5d0ac804decb62333ef82fede50f99af7e6c435754ab
Contents?: true
Size: 1.05 KB
Versions: 12
Compression:
Stored size: 1.05 KB
Contents
<% options = field.association_values.respond_to?(:call) ? field.association_values.call(self) : field.association_values %> <% values = self.instance_variable_get("@#{resource_name}").send("#{field.name}") %> <% subject_habtm_fieldname = "#{field.name.to_s.singularize}_ids" %> <% values.each{|value|%> <% option_tags = options.collect{|option| option_tag_attributes = {:value=>option[1]} option_tag_attributes[:selected] = "selected" if option[1] == value.id content_tag :option, option[0], option_tag_attributes }.join("").html_safe %> <div style="height:30px;"> <%= select_tag "#{resource_name}[#{subject_habtm_fieldname}][]", option_tags ,{:include_blank=>true} %> </div> <% } %> <% empty_fields = (values.size < 5) ? (5 - values.size) : 0 %> <% option_tags = options.collect{|option| content_tag :option, option[0], {:value=>option[1]} }.join("").html_safe %> <% empty_fields.times{ %> <div style="height:30px;"> <%= select_tag "#{resource_name}[#{subject_habtm_fieldname}][]", option_tags ,{:include_blank=>true} %> </div> <% } %>
Version data entries
12 entries across 12 versions & 1 rubygems