didi
didi

Reputation: 1

Required not working

The required in "brand" doesn't work and I don't know why.

View:

<%= simple_form_for(@equipment) do |f| %>
  <div class="form-inputs">
    <%= f.input :brand, required:true,:label => "test" %>

Controller:

params.require(:equipment)
  .permit(:brand, :acquisition_year, :energy_label)

Model:

validates_presence_of :brand, :message => "brand"

Upvotes: 0

Views: 39

Answers (2)

Igor Ivancha
Igor Ivancha

Reputation: 3451

Try without brackets in the form:

<%= simple_form_for @equipment do |f| %>
  <div class="form-inputs">
    <%= f.input :brand, required: true, label: 'test' %>
  </div>
  [...]
<% end >

Upvotes: 1

Nikola Todorovic
Nikola Todorovic

Reputation: 310

Try this:

<%= f.input :brand, required: true, label: "test" %>

See an empty space on 'true'

Upvotes: 0

Related Questions