Reputation: 71
I am new to ror. How do I give required attribute for an input[not the required label that is provided by ruby]. When I write this,
= form.text_field :title, {html:{required: "required"}}
browser shows this,
< input html="{:required=>"required"}" id="key_date_title"
name="key_date[title]" size="30" type="text">
Upvotes: 2
Views: 173
Reputation: 9173
If you look at text_field helper
. It requires 3 arguments: object_name, method and options = {}. You can pass in any standard HTML attributes directly in options argument.
= form.text_field :title, required: true
Upvotes: 2