![提交 提交](https://c1.lmlphp.com/image/static/default_avatar.gif)
本文介绍了将提交按钮图像添加到 Rails 表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Rails 中创建了一个用于提交评论的表单,我希望提交按钮是一个图像,而不是一个 HTML 按钮.在这一部分文档中,它说代码是 image_submit_tag
,但我无法让它在我的代码中工作.
这是我正在使用的:
真的做 |f|%><p><%= f.label :body, "添加评论" %><br/>名称
网站
Twitter
<%= f.text_area :body %></p><div id="评论表单"><div id="评论按钮"><p><%= f.image_submit_tag("comment-button.png") %></p>
<%结束%>
感谢您的帮助.
解决方案
你可以这样做:
ERB:
CSS:
input[type="submit"]{背景:网址(mybutton.png);}
I'm creating a form in Rails for submitting comments, and I want the submit button to be an image, rather than an HTML button. In this bit of documentation, it says the code is image_submit_tag
, but I can't get it to work in my code.
Here's what I'm working with:
<% form_for [@post, Comment.new], :remote => true do |f| %>
<p>
<%= f.label :body, "Add a comment" %><br />
Name <%= f.text_field :name %><br />
Website<%= f.text_field :website %><br />
Twitter<%= f.text_field :twitter %><br />
<%= f.text_area :body %>
</p>
<div id="comment-form">
<div id="comment-button"><p>
<%= f.image_submit_tag("comment-button.png") %></p>
</div>
</div>
<% end %>
Thanks for the help.
解决方案
You can do it like so:
ERB:
<%= f.submit "" %>
CSS:
input[type="submit"]
{
background:url(mybutton.png);
}
这篇关于将提交按钮图像添加到 Rails 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!