6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/form_props/action_view_extensions/form_helper.rb', line 6
def form_props(model: nil, scope: nil, url: nil, format: nil, **options, &block)
json = @__json
options = {
allow_method_names_outside_object: true,
controlled: false
}.merge!(options)
options.delete(:remote)
options[:local] = true
options[:skip_default_ids] = false
if model
if url != false
url ||= if format.nil?
polymorphic_path(model, {})
else
polymorphic_path(model, format: format)
end
end
model = convert_to_model(_object_for_form_builder(model))
scope ||= model_name_from_record_or_class(model).param_key
end
if block
options[:builder] = FormProps::FormBuilder
builder = instantiate_builder(scope, model, options)
json.inputs do
capture(builder, &block)
end
options[:multipart] ||= builder.multipart?
end
html_options = html_options_for_form_with(url, model, **options)
json. do
(json, html_options)
end
json.form(FormProps::Helper.format_keys(html_options))
end
|