Module: Bureaucrat::Formsets

Defined in:
lib/bureaucrat/formsets.rb

Defined Under Namespace

Classes: BaseFormSet, ManagementForm

Constant Summary collapse

TOTAL_FORM_COUNT =
:'TOTAL_FORMS'
INITIAL_FORM_COUNT =
:'INITIAL_FORMS'
ORDERING_FIELD_NAME =
:'ORDER'
DELETION_FIELD_NAME =
:'DELETE'

Class Method Summary collapse

Class Method Details

.all_valid?(formsets) ⇒ Boolean

Returns:

  • (Boolean)


248
249
250
251
252
253
254
# File 'lib/bureaucrat/formsets.rb', line 248

def all_valid?(formsets)
  valid = true
  formsets.each do |formset|
      valid = false unless formset.valid?
    end
  valid
end

.make_formset_class(form, options = {}) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/bureaucrat/formsets.rb', line 232

def make_formset_class(form, options={})
  formset = options.fetch(:formset, BaseFormSet)
  attrs = {
      :form => form,
      :extra => options.fetch(:extra, 1),
      :can_order => options.fetch(:can_order, false),
      :can_delete => options.fetch(:can_delete, false),
      :max_num => options.fetch(:max_num, 0)
    }
  Class.new(formset) do
      attrs.each do |name, value|
        define_method(name) { value }
      end
    end
end