diff --git a/TODO.rdoc b/TODO.rdoc index 219beb7f..61279e96 100644 --- a/TODO.rdoc +++ b/TODO.rdoc @@ -6,7 +6,7 @@ * Get default string options from column definition * Add support to default :prompt methods on datetime inputs * Add support to default label method -* Add support to label, error and hint calls +* Add support to f.label, f.error and f.hint calls * Improve readme with examples * :country, :time_zone, :group and :file types support diff --git a/lib/simple_form/action_view_extensions/form_helper.rb b/lib/simple_form/action_view_extensions/form_helper.rb index e64322ba..6476edb8 100644 --- a/lib/simple_form/action_view_extensions/form_helper.rb +++ b/lib/simple_form/action_view_extensions/form_helper.rb @@ -1,25 +1,15 @@ module SimpleForm module ActionViewExtensions module FormHelper - def simple_form_for(*args, &block) - build_simple_form(:form_for, *args, &block) + [:form_for, :fields_for, :remote_form_for].each do |helper| + class_eval <<-METHOD, __FILE__, __LINE__ + def simple_#{helper}(*args, &block) + options = args.extract_options! + options[:builder] = SimpleForm::FormBuilder + #{helper}(*(args << options), &block) + end + METHOD end - - def simple_fields_for(*args, &block) - build_simple_form(:fields_for, *args, &block) - end - - def simple_remote_form_for(*args, &block) - build_simple_form(:remote_form_for, *args, &block) - end - - private - - def build_simple_form(form_method, *args, &block) - options = args.extract_options! - options[:builder] = SimpleForm::FormBuilder - send(form_method, *(args << options), &block) - end end end end