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'
MAX_NUM_FORM_COUNT =
:'MAX_NUM_FORMS'
ORDERING_FIELD_NAME =
:'ORDER'
DELETION_FIELD_NAME =
:'DELETE'

Class Method Summary collapse

Class Method Details

.all_valid?(formsets) ⇒ Boolean

Returns:

  • (Boolean)


288
289
290
291
292
293
294
# File 'lib/bureaucrat/formsets.rb', line 288

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

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



273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/bureaucrat/formsets.rb', line 273

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