Ive made a nice editor in jQuery and i want to add it as a form helper method.
how would i go about making a new form helper method?
ideally id like to be able to call:
f.nice_editor :field
Ive made a nice editor in jQuery and i want to add it as a form helper method.
how would i go about making a new form helper method?
ideally id like to be able to call:
f.nice_editor :field
after some research i found that this works:
class ActionView::Helpers::FormBuilder
def nice_editor(conf)
#stuff to draw the editor
end
end
"conf" would have all the symbol options passed to it from the view. it works fine with f.
The object yielded to form_for
is an instance of ActionView::Helpers::FormBuilder
. So all you have to do is to add instance methods there.
class ActionView::Helpers::FormBuilder
def custom_field(...)
...
end
end