Nirajan Pokharel
Nirajan Pokharel

Reputation: 1139

Does rails not support html list attribute on input tag?

What I'm trying to achieve is something like this in rails

https://jsfiddle.net/uxc45hcs/

But rails doesn't seems to support HTML attribute "list"

.col-md-2.execute_at_input = f.input :execute_at, label: "Execute Attt", placeholder: " In Minutes ", list: 'listid'

The above code outputs the following:

<input class="string optional form-control" placeholder=" In Minutes " type="text" value="" name="execute_at" data-validate="true">

Where as it should be:

<input class="string optional form-control" placeholder=" In Minutes " type="text" value="" name="execute_at" data-validate="true" list="listid">

Am I doing something wrong?

Upvotes: 0

Views: 163

Answers (2)

Deepak Mahakale
Deepak Mahakale

Reputation: 23711

This works with text_field

.col-md-2.execute_at_input= f.text_field :execute_at, label: "Execute Attt", placeholder: " In Minutes ", list: 'listid'

This resulted in following output

<div class="col-md-2 execute_at_input">
  <input id="execute_at" label="Execute Attt" list="listid" name="execute_at" placeholder=" In Minutes " size="30" type="text" maxlength="255">
</div>

If you are using Formtastic check for the syntax

Upvotes: 1

Christian-G
Christian-G

Reputation: 2361

Something like this should work: (tested in rails 5)

<%= f.text_field :name, :class => 'form-control col-md-2', :placeholder => 'In Minutes', :list => "listid" %>

Upvotes: 1

Related Questions