I've got js hooks into formtastic-generated IDs for inputs. The input ids are of the form MODELNAME_INPUTNAME. Because our page is spread out among several pages, and usually being A/B tested, the modelname is constantly changing, say from "candidate_application_page3b" to "candidate_application_page1". That means a lot of churn to our JS code, or a layer of abstraction to translate IDs. Both of those make the JS harder to maintain.
The way we'd like to solve this is by changing the way formtastic calculates it's id names.
Does anything exist for this in formtastic? If we could override it's preference to include the model name in the input IDs at the semantic_form_for
level, that would be the easiest thing.
We found the :namespace
argument, but that only tacks additional words to the beginning of the id, it doesn't let us change the modelname bit.
You were close in your above comment, can use the :as
option to do this.
<%= semantic_form_for @post, as: "article" do |f| %>
<%= form.input :title %> <!-- #article_title -->
<% end %>