Extend ActionView::Helpers::FormHelper or add a simple helper
I was writing a rails plugin/gem and I need to set up some FormHelper
methods options as maxlength or minlength and I was wondering wich option
is better, adding a simple helper to the plugin/gem or extending
FormHelpers methods options (if that is posible) and add some option that
setup the values I want.
With a helper
f.text_field :name, maxlength: maxlength_for(@resource, :attribute)
Extending FormHelper methods
f.text_field :name, gem_validation: true
In both cases the result must be like this:
f.text_field :name, maxlength: 100
Note: 100 is the value that the plugin/gem returns.
No comments:
Post a Comment