Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove size property from input generated by text_field?

I have an .erb file with form template that uses form_for helper to generate form, and some of their fields generated with text_field method. In resulting HTML I see size properties are added to every input generated with aforementioned method.

I want to control input sizes with CSS and that size property prevents me from doing it. Is there any way to tell text_field method that I don't want them?

I tried to pass :size => nil as option to that method, but that didn't help.

like image 285
n0rd Avatar asked Mar 29 '09 20:03

n0rd


2 Answers

This worked for me

<%= f.text_field :title, :size => nil %>
like image 53
iJK Avatar answered Sep 24 '22 08:09

iJK


You can use CSS or the :size option to control the size of input fields. I'm not sure if there is an option to remove the size attribute, I've always just ignored it and set the width of input fields with CSS.

like image 45
danengle Avatar answered Sep 22 '22 08:09

danengle