Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SemanticFormBuilder.semantic_fields_for now uses the builder specifie…

…d in SemanticFormHelper.builder (configurable), rather than assuming that the builder is always SemanticFormBuilder, correcting issue #41
  • Loading branch information...
commit 51bbaf925756322636267a505f91509b123665dd 1 parent c434803
@justinfrench authored
Showing with 10 additions and 2 deletions.
  1. +4 −0 README.textile
  2. +4 −0 lib/formtastic.rb
  3. +2 −2 spec/formtastic_spec.rb
View
4 README.textile
@@ -418,6 +418,10 @@ If you wish, put something like this in config/initializers/formtastic_config.rb
# Default value: false. Overridden for specific fields by setting value to true,
# i.e. :label => true, or :hint => true (or opposite depending on initialized value)
# Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
+
+ # If you want to subclass SemanticFormBuilder to add/change the behavior to suit your needs, you
+ # can specify the builder class.
+ # Formtastic::SemanticFormHelper.builder = MyCustomBuilder
</pre>
h2. Status
View
4 lib/formtastic.rb
@@ -1285,6 +1285,10 @@ module SemanticFormHelper
def self.builder=(val)
@@builder = val
end
+
+ def self.builder
+ @@builder
+ end
[:form_for, :fields_for, :form_remote_for, :remote_form_for].each do |meth|
src = <<-END_SRC
View
4 spec/formtastic_spec.rb
@@ -262,10 +262,10 @@ def custom(arg1, arg2, options = {})
@new_post.stub!(:author).and_return(Author.new)
end
- it 'yields an instance of SemanticFormBuilder' do
+ it 'yields an instance of SemanticFormHelper.builder' do
semantic_form_for(@new_post) do |builder|
builder.semantic_fields_for(:author) do |nested_builder|
- nested_builder.class.should == Formtastic::SemanticFormBuilder
+ nested_builder.class.should == Formtastic::SemanticFormHelper.builder
end
end
end

2 comments on commit 51bbaf9

@grimen
def self.builder=(val)
  @@builder = val
end

def self.builder
  @@builder
end

...maybe should be DRYed up with?:

cattr_accessor :builder
@grimen

Forget about that ^, I didn't see you already replaced it with mattr_accessor. Wohoo! =)

Please sign in to comment.
Something went wrong with that request. Please try again.