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
|
# File 'lib/arbre/form/base.rb', line 9
def build(
content = nil,
*args,
action: '/',
method: :post,
multipart: false,
enforce_utf8: true,
remote: false,
authenticity_token: default_auth_token(action, method),
token_name: default_token_name,
**attributes
)
raise InvalidMethodError, "`#{method}` is not a valid HTTP method" unless ALLOWED_METHODS.include?(method)
set_attribute :action, action
set_attribute :enctype, 'multipart/form-data' if multipart
form_method = FORM_METHODS.include?(method) ? method : :post
set_attribute :method, form_method.to_s.upcase
set_attribute :'data-remote', true if remote
super content, *args, attributes
within(self) do
input(type: :hidden, name: 'utf8', value: '✓') if enforce_utf8
input(type: :hidden, name: '_method', value: method.to_s.upcase) if method != form_method
input(type: :hidden, name: token_name, value: authenticity_token) if authenticity_token
end
end
|