Kostya Kokosko
Kostya Kokosko

Reputation: 45

set "required" to text_field by rails view to validation on client side

In my rails partial (_form.html.erb) I wrote this:

<%= f.text_field :title, required: true %>

The generated html is:

<input required="required" type="text" name="task[title]" id="task_title">

It works fine, but I want this:

<input type="text" name="task[title]" id="task_title" required>

How to set just 'required' into tag?

Upvotes: 0

Views: 3138

Answers (1)

bsvin33t
bsvin33t

Reputation: 638

Please see this post. There is no such thing as a valueless attribute.

So, no matter what you write required or required='true' or required='false', would all mean the same thing. The input is required.

Upvotes: 2

Related Questions