Kit*_* Ho 7 html ruby ruby-on-rails simple-form
当我使用rails时,我使用简单的表单gem创建一个简单的表单
我创建了一个这样的表单
<%= simple_form_for @user do |f| %>
<%= f.input :username %>
<%= f.input :password %>
<%= f.button :submit %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但我想在每个字段旁边添加一个默认的图像元素.我怎么能实现这一目标?
我试试这个
<%= simple_form_for @user do |f| %>
<%= f.input :username % >
<img xxxx>
<%= f.input :password %>
<img xxxx>
<%= f.button :submit %>
<img xxxx>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但我不会工作,因为它将包装为每个元素字段的新行.
dsp*_*cer -2
我建议考虑使用f.labelandf.input_field而不是,f.input因为它允许您根据需要放置组件并在您想要的位置添加图像。
查看Simple_Form文档以获取更多信息和示例。
例子:
<%= simple_form_for @user do |f| %>
<%= f.label :username %>
<%= f.input_field :username %>
<img xxxx>
<%= f.button :submit %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5229 次 |
| 最近记录: |