Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form animations broken after an erroneous submit #46

Closed
dedles opened this issue Jul 9, 2015 · 4 comments
Closed

Form animations broken after an erroneous submit #46

dedles opened this issue Jul 9, 2015 · 4 comments

Comments

@dedles
Copy link

dedles commented Jul 9, 2015

After submitting a form with some incorrect input the labels and text becomes static and will not move to the top as they do when the field is selected or when the page loads.
see:
screen shot 2015-07-09 at 6 50 03 pm

My form code looks like this:

<%= form_for(@school, :html => { multipart: true }) do |f| %>
    <% if @school.errors.any? %>
      <div id="error-content" class="card-panel red lighten-4">
        <div class="row">
                <a id="button-dismiss"class="btn-floating btn-medium center teal lighten-3"><i class="material-icons">add</i></a>
          <h5><%= pluralize(@school.errors.count, "error") %> prohibited this school from being saved:</h5>
        </div>
        <div class="col s4">
          <ul>
          <% @school.errors.full_messages.each do |message| %>
            <li>- <%= message %></li>
          <% end %>
          </ul>
        </div>
      </div>
    <% end %>
    <div class="row">
        <div class="col s12">
        <div class="row">
              <div class="input-field col s10">
                  <i class="material-icons prefix">business</i>
                <%= f.label :name %>
                <%= f.text_field :name, placeholder: "Please use appropriate punctuation" %>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s10">
                  <i class="material-icons prefix">language</i>
                <%= f.label :address %>
                <%= f.text_field :address, placeholder: "ex. 123 Fake St., Boston, USA" %>
              </div>
            </div>

            <div class="row">
              <div class="input-field col s10">
                  <i class="material-icons prefix">phone</i>
                <%= f.label :phone %>
                <%= f.text_field :phone, placeholder: "in the format: (123) 456-7890" %>
              </div>
            </div>

           <div class="row">
              <div class="input-field col s10">
              <i class="material-icons prefix">web</i>
                <%= f.label :website %>
                <%= f.text_field :website, placeholder: "http://www.wonderschool.com" %>
              </div>
            </div>
            <div class="row">
              <div class="input-field col s3">
                    <%= button_tag( :class => "waves-effect waves-light btn") do %>
                      Create<i class="material-icons">send</i>
                    <% end %>
              </div>
            </div>  
        </div>
    </div>
<% end %>

I've tried disabling turbolinks and using the jquery.turbolinks gem. But neither approach has worked. Any advise would be really appreciated

@mkhairi
Copy link
Owner

mkhairi commented Jul 13, 2015

hit @dedles, i guess this causes by rails "field-with-errors" wrapper. Check this out..

@ghost
Copy link

ghost commented Dec 28, 2015

This issue still exists. It would be awesome if the gem included a wrapper override.

I also used an override in my application.rb like this:

config.action_view.field_error_proc = Proc.new { |html_tag, instance| html_tag }

To switch it off, but it would be awesome to have it red underlined, and a bit quicker to redraw.

@silverdr
Copy link

silverdr commented Sep 3, 2016

@ICT22 +1, Yes, turning wrappers off is not really a solution.

@silverdr
Copy link

silverdr commented Sep 3, 2016

A somewhat better workaround based on this stack post:

# config/initializers/field_with_errors_override.rb
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
    class_attr_index = html_tag.index 'class="'

    if class_attr_index
        html_tag.insert class_attr_index+7, 'invalid '
    else
        html_tag.insert html_tag.index('>'), ' class="invalid"'
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants