File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,40 @@ class FormBuilder < ActionView::Helpers::FormBuilder
33 ( field_helpers - [ :label , :fields_for ] ) . each do |selector |
44 class_eval <<-RUBY_EVAL , __FILE__ , __LINE__ + 1
55 def #{ selector } (method, options = {})
6+ resolve_vue_options(options)
67 options[:"v-model"] ||= "\# {@object_name}.\# {method}"
78 super(method, options)
89 end
910 RUBY_EVAL
1011 end
12+
13+ def label ( method , text = nil , options = { } , &block )
14+ resolve_vue_options ( options )
15+ super ( method , text , options , &block )
16+ end
17+
18+ def submit ( value = nil , options = { } )
19+ resolve_vue_options ( options )
20+ super ( value , options )
21+ end
22+
23+ def button ( value = nil , options = { } , &block )
24+ resolve_vue_options ( options )
25+ super ( value , options , &block )
26+ end
27+
28+ private def resolve_vue_options ( options )
29+ if options [ :v ] . kind_of? ( Hash )
30+ h = options . delete ( :v )
31+ h . each do |key , value |
32+ case key
33+ when /\A [:@]/
34+ options [ key ] = value
35+ else
36+ options [ :"v-#{ key } " ] = value
37+ end
38+ end
39+ end
40+ end
1141 end
1242end
You can’t perform that action at this time.
0 commit comments