1
votes

I'm trying to create a simple form for signing in however am getting strange validation errors before it submits. For example when signing up an admin, if I open up the devise view for registering, I have the following code:

<h2>Sign up</h2>

<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), novalidate: "novalidate") do |f| %>
  <%= f.error_notification %>

  <div class="form-inputs">
    <%= f.input :email, autofocus: true, input_html: { value: booking_email } %>
    <%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>
    <%= f.input :password_confirmation, required: true %>
    <% if params[:invite_token] || params[:organiser_token] %>
      <%= f.hidden_field :booking_id, value: booking_from_params.id %>
    <% end %>
    <% if params[:organiser_token] %>
      <%= f.hidden_field :organiser, value: organiser_registration? %>
    <% end %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Sign up" %>
  </div>
<% end %>

<%= render "devise/shared/links" %>

When I try to log in, register, or do anything involving a 'f.input' field, I receive the following error:

"Please lengthen this text to 255 characters or more, you are currently using 7 characters"

To the best of my knowledge nobody has added any validations either at the front end or back end. I'm not allowed to submit the form as when I click on submit the error message pops up before anything is sent to the rails server.

I think this is HTML 5 validation but I'm not sure.. I"ve tried adding in the novalidate attribute to the form but with no joy.

If anyone can tell me how I can either disable this validation or find out where in my app it is being called from that would be greatly appreciated. Searching through the project for the error message returned nothing.

Thanks in advance.

******** EDIT ********

Changing f.input to f.text_area removes the validation. If anyone can tell me where I can find client side validation for simple_form_for attributes that would be hugely appreciated

1

1 Answers

2
votes

If anyone comes up across the same... run

rails generate simple_form:install

Then navigate to config/initializers/simple_form.rb, and remove the following 2 lines:

b.optional :maxlength
b.optional :minlength

Fixed it for me.