0

我有一个 Rails 应用程序,并且正在使用 haml 和 bootstrap。在我的表单中,我有两个用于输入文本的字段,并且只显示一个,具体取决于我在控制器中设置的变量。如果有一个文本区域,我想调整它的大小,并且:rows属性有效,但列无效。

我也尝试使用%div :class => 'span6'来扩大 text_area,但它似乎不起作用。

= form_for [@lesson_layout, @layout_field] do |f|
  .field
    = f.label :field_name
    = f.text_field :field_name
  - case @layout_type
  - when "Text Field"
    .field
      = f.label :field_value
      = f.text_field :field_value
    - when "Text Area"
      .field
        = f.label :field_value_long
        = f.text_area :field_value_long, :rows => 5, :placeholder => 'Enter text.'

.actions
  = f.submit

编辑

尝试了以下代码,它并没有改变盒子的大小。

.field
  = f.label :field_value_long
  = f.text_area :field_value_long, :rows => 5, :placeholder => 'Enter text using markdown.', :html => { :style => "width:300em" }
4

2 回答 2

11

像这样的东西应该工作:
= f.text_area :field_value_long, :rows => 5, :class => "span6", :placeholder => 'Enter text.'

于 2012-12-14T14:44:41.020 回答
1
f.text_area( 
  :field_value_long, 
  :rows => 5, 
  :placeholder => 'Enter text.', 
  :html => { :style => "width:20em !important" }
)

或者

f.text_area( 
  :field_value_long, 
  :rows => 5, 
  :placeholder => 'Enter text.', 
  :html => { :class => "my_wide_class" }
)
于 2012-12-14T14:40:58.680 回答