【问题标题】:Rails: Simpleform inside of table input type = text_area- how to set its height?Rails:表格输入类型中的Simpleform = text_area-如何设置其高度?
【发布时间】:2012-06-16 22:57:51
【问题描述】:

我正在为我的 rails 应用程序使用“Simpleform”gem,并且我在表格中嵌入了一个表单。

表单的元素之一是 text_area。但是,由于这种输入类型,表格的整行非常高。我想设置它的高度,这样行就不会那么高了。

我该怎么做我尝试了以下但似乎没有改变任何东西

 <% @listings.each do |listing| %>  
<%= simple_form_for(listing, :html => {:multipart => true, :class=> '.form-inline'} ) do |f| %>
<tr>
    <td><%= listing.id %></td>
    <td><%= listing.name %></td>
    <td><%= f.input :telephone %></td>
    <td><%= f.input :fax %></td>
    <td><%= f.input :suite %></td>

    <td> <%= f.input :notes, :size => 5 %></td>
        <td> <%= f.button :submit %></td>
</tr>
<% end %>
<% end %>

任何建议将不胜感激

【问题讨论】:

  • 你尝试过 CSS,找到表单 id 并将所需的高度应用于 textarea 属性。

标签: ruby-on-rails ruby forms html-table simple-form


【解决方案1】:

您可以使用本提交的代码:

<td> <%= f.input :notes, :input_html => { :rows => 5 } %></td>

但是,使用简单表单使用的辅助类可能是一个更好的主意。从记忆中,并使用您的自定义类,这样的事情应该可以工作:

.form-inline .text{
  height: 300px;
}

这使样式在您的 CSS 中保持独立,应该是这样。

【讨论】:

    【解决方案2】:

    我想你想要这样的东西:

    <td> <%= f.input :notes, :input_html => { :rows => 5 } %></td>
    

    input_html 选项将向生成的 HTML 标记添加任意属性。对于文本区域,没有“大小”属性,只有“列”或“行”。

    我自己没有对此进行测试,但我已将 :input_html 用于其他 HTML 属性。告诉我你过得怎么样!

    【讨论】:

      猜你喜欢
      • 2012-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多