Class: ActiveAdmin::Views::ActiveAdminForm
- Inherits:
-
FormtasticProxy
- Object
- Arbre::Rails::Forms::FormBuilderProxy
- FormtasticProxy
- ActiveAdmin::Views::ActiveAdminForm
show all
- Defined in:
- lib/active_admin/views/components/active_admin_form.rb
Instance Method Summary
collapse
#closing_tag, #opening_tag, #split_string_on, #to_s
Instance Method Details
#actions(*args, &block) ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 75
def actions(*args, &block)
if block
insert_tag(SemanticActionsProxy, form_builder, *args, &block)
else
add_create_another_checkbox
actions(*args) { commit_action_with_cancel_link }
end
end
|
#add_create_another_checkbox ⇒ Object
89
90
91
92
93
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 89
def add_create_another_checkbox
if %w(new create).include?(helpers.action_name) && active_admin_config && active_admin_config.create_another
current_arbre_element.add_child(create_another_checkbox)
end
end
|
#build(resource, options = {}, &block) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 27
def build(resource, options = {}, &block)
@resource = resource
options = options.deep_dup
options[:builder] ||= ActiveAdmin::FormBuilder
form_string = helpers.semantic_form_for(resource, options) do |f|
@form_builder = f
end
@opening_tag, @closing_tag = split_string_on(form_string, "</form>")
instance_eval(&block) if block
if multipart? && !@opening_tag.include?('multipart')
@opening_tag.sub!(/<form/, '<form enctype="multipart/form-data"')
end
end
|
#commit_action_with_cancel_link ⇒ Object
84
85
86
87
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 84
def commit_action_with_cancel_link
action(:submit)
cancel_link
end
|
#has_many(*args, &block) ⇒ Object
95
96
97
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 95
def has_many(*args, &block)
insert_tag(HasManyProxy, form_builder, *args, &block)
end
|
71
72
73
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 71
def input(*args)
proxy_call_to_form :input, *args
end
|
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 45
def inputs(*args, &block)
if block
form_builder.template.assigns[:has_many_block] = true
end
if block && block.arity == 0
wrapped_block = proc do
wrap_it = form_builder.already_in_an_inputs_block ? true : false
form_builder.already_in_an_inputs_block = true
content = form_builder.template.capture do
block.call
end
form_builder.already_in_an_inputs_block = wrap_it
content
end
insert_tag(SemanticInputsProxy, form_builder, *args, &wrapped_block)
else
opts = args.
opts[:except] ||= []
ActiveAdmin.application.filter_attributes.each { |e| opts[:except] << e }
args << opts
proxy_call_to_form(:inputs, *args, &block)
end
end
|
#multipart? ⇒ Boolean
99
100
101
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 99
def multipart?
form_builder && form_builder.multipart?
end
|
#object ⇒ Object
103
104
105
|
# File 'lib/active_admin/views/components/active_admin_form.rb', line 103
def object
form_builder.object
end
|