Method: Lolita::Configuration::Tab::Base#fields_in_groups

Defined in:
lib/lolita/configuration/tab.rb

#fields_in_groupsObject

Return fields in groups where in one group are fields for same model. It return all groups as array or yield each group when block is given.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/lolita/configuration/tab.rb', line 138

def fields_in_groups()
  groups = []
  current_class = nil
  self.fields.each do |group_field|

    klass = group_field.dbi.klass
    if current_class == klass
      groups.last << group_field
    else
      groups << [group_field]
    end
    current_class = klass
  end
  if block_given?
    groups.each{|group| yield group }
  else
    groups
  end
end