Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: how do I set ID or Name attribute in text_field_tag?

<%= text_field_tag :barcode, params[:barcode] %>

generates

<input id="barcode" name="barcode" type="text"></input>

but I need

<input type="text" name="barcode" id="autocomplete"></input>

But in the documentation I did not find a way how to change the ID attribute.

I need to use a text_field_tag because it fills the textbox with params if submit fails.

like image 974
Muflix Avatar asked Sep 24 '13 18:09

Muflix


2 Answers

try this

<%= text_field_tag :barcode, params[:barcode], id: 'autocomplete' %>
like image 95
n_i_c_k Avatar answered Sep 22 '22 21:09

n_i_c_k


You can also try this...

<%= text_field_tag :barcode, params[:barcode], :id => 'autocomplete' %>
like image 35
amit karsale Avatar answered Sep 24 '22 21:09

amit karsale