Module: Bureaucrat::Formsets

Defined in:
lib/bureaucrat/formsets.rb

Defined Under Namespace

Classes: BaseFormSet, ManagementForm

Constant Summary

TOTAL_FORM_COUNT =
TOTAL_FORMS
INITIAL_FORM_COUNT =
INITIAL_FORMS
MAX_NUM_FORM_COUNT =
MAX_NUM_FORMS
ORDERING_FIELD_NAME =
ORDER
DELETION_FIELD_NAME =
DELETE

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) all_valid?(formsets)

Returns:

  • (Boolean)


267
268
269
270
271
272
273
# File 'lib/bureaucrat/formsets.rb', line 267

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

- (Object) make_formset_class(form, options = {})



252
253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/bureaucrat/formsets.rb', line 252

def make_formset_class(form, options={})
  formset = options.fetch(:formset, BaseFormSet)

  Class.new(formset) do
    define_method :set_defaults do
      @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)
    end
    private :set_defaults
  end
end