Unable to override :builder paramters #41

Closed
twalpole opened this Issue Sep 3, 2009 · 8 comments

Comments

Projects
None yet
2 participants
Collaborator

twalpole commented Sep 3, 2009

If I derive a new builder from SemanticFormBuilder, I can set Formtastic::SemanticFormHelper::builder to make my new class the deafult used by SematincFormHelper::sematic_form_for, SemanticFormHelper::semantic_fields_for, etc. However SemanticFormBuilder::semantic_fields_for hardcodes :builder as Formtastic::SemanticFormBuilder, and adds it to the options with merge, which prevents overriding it when called. It would be better if the class used for :builder was settable, or reverse_merge was used so that if it is passed in the options it gets used as specified

Owner

justinfrench commented Sep 3, 2009

This is absolutely something that should be supported. You should be able to set Formtastic::SemanticFormHelper.builder = YourCustomBuilder in your initializer. I think there may be a few gaps in the implementation around semantic_fields_for and nested models (which I'll create a new issue for), but give it a try and let me know what we're missing.

Owner

justinfrench commented Sep 3, 2009

Closing this issue for now, please feel free to re-open.

Collaborator

twalpole commented Sep 3, 2009

Yes - it is exactly the issue with nested models that I'm hitting currently - also using reverse_merge instead of merge when bringing in the default builder parameter (in SemanticFormBuilder::semantic_fields_for) would allow the user to pass in a :builder option and have it used

Owner

justinfrench commented Sep 6, 2009

I've fixed this on my local fork, but I'm tethering on an iPhone and can't seem to push right now.... So I'll push this up soon and get you to verify before cutting a new gem.

Owner

justinfrench commented Sep 6, 2009

Ok, that's better. See http://github.com/justinfrench/formtastic/commit/51bbaf925756322636267a505f91509b123665dd. I you can install the plugin on edge and verify, I'll cut a new gem. Closing this issue for now.

Collaborator

twalpole commented Sep 6, 2009

Doesnt seem to have fully fixed the issue I'm having because of the hardcoded opts.merge!(:builder => Formtastic::SemanticFormBuilder)
in SemanticFormBuilder::semantic_fields_for

Owner

justinfrench commented Sep 6, 2009

Gah, I fixed that! Not sure what happened in my commit, have pushed up a subsequent commit sorry 1182961.

Owner

justinfrench commented Sep 7, 2009

included in 0.2.3 gem

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment