Class: AdminAssistant::MultiFormView

Inherits:
Object
  • Object
show all
Includes:
FormViewMethods
Defined in:
lib/admin_assistant/form_view.rb

Defined Under Namespace

Classes: Builder, RecordsForForm

Instance Method Summary collapse

Methods included from FormViewMethods

#action, #controller

Constructor Details

#initialize(records, admin_assistant, action_view) ⇒ MultiFormView

Returns a new instance of MultiFormView.



72
73
74
75
76
77
78
# File 'lib/admin_assistant/form_view.rb', line 72

def initialize(records, admin_assistant, action_view)
  @records, @admin_assistant, @action_view =
      records, admin_assistant, action_view
  @sub_form_views = @records.map { |record|
    AdminAssistant::FormView.new(record, @admin_assistant, @action_view)
  }
end

Instance Method Details

#columnsObject



80
81
82
# File 'lib/admin_assistant/form_view.rb', line 80

def columns
  @sub_form_views.first.columns
end

#extra_submit_buttonsObject



84
85
86
# File 'lib/admin_assistant/form_view.rb', line 84

def extra_submit_buttons
  @sub_form_views.first.extra_submit_buttons
end

#form_for_argsObject



88
89
90
91
92
93
94
95
96
97
# File 'lib/admin_assistant/form_view.rb', line 88

def form_for_args
  opts = {
    :builder => AdminAssistant::MultiFormView::Builder,
    :sub_form_views => @sub_form_views, :url => {:action => action}
  }
  [
    RecordsForForm.new(@records),
    opts.merge(:as => @records.first.class.name.underscore.to_sym)
  ]
end

#submit_valueObject



99
100
101
# File 'lib/admin_assistant/form_view.rb', line 99

def submit_value
  @sub_form_views.first.submit_value
end

#titleObject



103
104
105
# File 'lib/admin_assistant/form_view.rb', line 103

def title
  @sub_form_views.first.title
end