views:

35

answers:

2

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
A: 

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.

Arcath
+1  A: 

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
August Lilleaas