How do I force the ID for an input field in my form_helper?

I would like the id for my input to be user[email] and not user_email. But everything I try doesn't work.

I am using the latest version of Devise for these gems.

This is my form:

  <%= form_for(resource, :as => resource_name, :class => "send-with-ajax", :url => user_registration_path(resource), :validate => true, :html => { :id => 'user_new' }) do |f| %>
                    <div class="six columns alpha"> 
      <%= f.text_field :email, :id => 'user[email]', :placeholder => "", :input_html => {:autofocus => true}, :validate => true %>
                        <div class="three columns sign-up alpha">
      <%= f.submit :label => "Submit", :value => "Sign Me Up!" %>
                          <div class="ajax-response"><%= devise_error_messages! %></div>
  <% end %>

This is the HTML produced:

<form accept-charset="UTF-8" action="/users" class="formtastic user" data-validate="true" id="user_new" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="khstyw72jj44kkhaskdya3hkb3ba3lkxmw4=" /></div>
                        <div class="six columns alpha"> 
              <input data-validate="true" id="user_email" input_html="{:autofocus=&gt;true}" name="user[email]" placeholder="" size="30" type="text" />
                            <div class="three columns sign-up alpha">
              <input label="Submit" name="commit" type="submit" value="Sign Me Up!" />
                              <div class="ajax-response"></div>



ID cannot contain square brackets, so it might be the cause, that Rails changes it.

See: What are valid values for the id attribute in HTML? and What characters are allowed in DOM IDs?

Seems I had to restart my server to get the form_helper changes to be reflected.

So :id => user[email] does work.

Need Your Help

Adjacent CAShapeLayer Antialiasing Issue

ios objective-c graphics core-animation quartz-graphics

I'm drawing a pie chart using a CAShapeLayer for each slice of the pie. Even when the end angle of one pie slice is equal to the start angle of the adjacent slice, antialiasing is resulting in the

Maven JBoss plugin update from 1.3.1 to 1.3.2 caused deployment to fail

deployment maven-2 jboss maven-plugin

By accident I updated Maven JBoss plugin to version 1.3.2. After that the deployment failed silently, no attempt to connect JBoss was made. Eventually we found out the version change and reverted b...