Class: AdminAssistant::FormView
- Inherits:
-
Object
- Object
- AdminAssistant::FormView
- Includes:
- FormViewMethods
- Defined in:
- lib/admin_assistant/form_view.rb
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
- #column_names ⇒ Object
- #columns ⇒ Object
- #extra_submit_buttons ⇒ Object
- #form_for_args ⇒ Object
-
#initialize(record, admin_assistant, action_view) ⇒ FormView
constructor
A new instance of FormView.
- #model_class ⇒ Object
- #settings ⇒ Object
- #submit_value ⇒ Object
- #title ⇒ Object
Methods included from FormViewMethods
Constructor Details
#initialize(record, admin_assistant, action_view) ⇒ FormView
Returns a new instance of FormView.
21 22 23 24 |
# File 'lib/admin_assistant/form_view.rb', line 21 def initialize(record, admin_assistant, action_view) @record, @admin_assistant, @action_view = record, admin_assistant, action_view end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record.
19 20 21 |
# File 'lib/admin_assistant/form_view.rb', line 19 def record @record end |
Instance Method Details
#column_names ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/admin_assistant/form_view.rb', line 26 def column_names if %w(new create).include?(@action_view.action_name) settings.columns_for_new elsif %w(edit update).include?(@action_view.action_name) settings.columns_for_edit end end |
#columns ⇒ Object
34 35 36 37 38 |
# File 'lib/admin_assistant/form_view.rb', line 34 def columns @admin_assistant.accumulate_columns(column_names).map { |c| c.form_view @action_view, @admin_assistant } end |
#extra_submit_buttons ⇒ Object
40 41 42 |
# File 'lib/admin_assistant/form_view.rb', line 40 def settings. end |
#form_for_args ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/admin_assistant/form_view.rb', line 44 def form_for_args args = {:url => {:action => action, :id => @record.id}} if !@admin_assistant..empty? args[:html] = {:multipart => true} end args end |
#model_class ⇒ Object
52 53 54 |
# File 'lib/admin_assistant/form_view.rb', line 52 def model_class @admin_assistant.model_class end |
#settings ⇒ Object
56 57 58 |
# File 'lib/admin_assistant/form_view.rb', line 56 def settings @admin_assistant.form_settings end |
#submit_value ⇒ Object
60 61 62 |
# File 'lib/admin_assistant/form_view.rb', line 60 def submit_value action.capitalize end |
#title ⇒ Object
64 65 66 |
# File 'lib/admin_assistant/form_view.rb', line 64 def title (@record.id ? "Edit" : "New") + " #{@admin_assistant.model_class_name}" end |