繁体   English   中英

f。输入行不起作用Rails 4

[英]f.input rows not working Rails 4

但是,在我的Rails 4应用程序上使用简单格式和f.input时,行数不起作用。 仅显示1行。

<%= simple_form_for(@article) do |f| %>
<%= f.error_notification %>

  <%= f.input :whyrating, :input_html => { :rows => 5 } %>

<% end %>

也尝试了没有input_html

<%= f.input :whyrating, label:"Why it deserves this rating", :rows => 5 } %>

有谁没有理由吗? 我敢肯定这很简单,但终究无法解决。

代替创建“ <%= f.input:whyrating,标签:”为什么值得这个等级“,:rows => 5}%>”,您可以使用“ <%= f.text_area:whyrating,label:”为什么值得此评级”}%>在rails 4中。

我选择了f.text_area ,效果很好。

您可以使用表单输入的input_html属性来指定行数。 此外,在Rails 4+中,您可以简化代码,例如:

<%= f.input :whyrating, input_html: { rows: "5" } %>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM