设置输入字段的大小

时间:2013-08-07 22:47:35

标签: ruby-on-rails

我有一个Rails表单,我尝试使用:size:cols => "30", :rows => "10"更改默认字段的大小,如下面的代码所示。但是,表单字段保持默认大小。我有什么不对的吗?

<%= d.text_field c, :class => 'random', :value => "#{c}", :size => "30", :id => 'correction_data_'"#{c.parameterize}"%>

或者这样

<%= d.text_field @title, :class => 'random', :value => "#{@title}", :cols => "30", :rows => "10", :id => 'correction_data_'"#{@title.parameterize}"%>

1 个答案:

答案 0 :(得分:0)

text_field不考虑rowscols属性,但会考虑size属性。 text_area考虑了rowscolssize属性。

text_field:

<%= d.text_field c, :class => 'random', :value => "#{c}", :size => 30, :id => 'correction_data_'"#{c.parameterize}" %>

text_area使用行和列:

<%= d.text_area @title, :class => 'random', :value => "#{@title}", :cols => 30, :rows => 10, :id => 'correction_data_'"#{@title.parameterize}" %>

text_area使用大小:

<%= d.text_area @title, :class => 'random', :value => "#{@title}", :size => "30x10", :id => 'correction_data_'"#{@title.parameterize}" %>