Rails: how to set id or attribute name in text_field_tag?

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

he 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 to change the identifier attribute.

I need to use text_field_tag ​​because it fills the text field with parameters if submit doesn't work.

If I think that I'm worried, if I change the identifier, it does not populate the parameter ?!

+8
ruby-on-rails-3
source share
3 answers

try it

 <%= text_field_tag :barcode, params[:barcode], id: 'autocomplete' %> 
+20
source share

You can also try this ...

 <%= text_field_tag :barcode, params[:barcode], :id => 'autocomplete' %> 
+2
source share

try it

'<% = text_field_tag ​​"name_text", "value_text" ,: class => "txBox" ,: size => 15%>'

working

<input type="text" size="15" name="name_text" id="name_text" values="" class="txBox">

0
source share

All Articles