stephenemmanuel
stephenemmanuel

Reputation: 43

Rails Simple Form Required Field Not Working

I have a simple form, I have made the name field required, however, I am still able to submit this form without providing a name. The HTML validations are not kicking in.

<%= simple_form_for @company do |f| %>
  <%= f.input :name, required: true %>
  <%= f.button :submit %>
<% end %>

Is there something wrong with the simple form syntax here?

Upvotes: 4

Views: 1785

Answers (1)

Adim
Adim

Reputation: 1776

What worked for me was to enter the simpleform initializer configuration i.e config/initializers/simple_form.rb and then change config.browser_validations to true.

I think it's turned off by default for some reason

Upvotes: 8

Related Questions