html – 嵌入输入f.label(rails表单生成)

html – 嵌入输入f.label(rails表单生成),第1张

概述我想使用f.label方法创建我的表单元素标签,但是 – 我想要将表单元素嵌套在标签内。这可能吗? – 从W3C – To associate a label with another control implicitly, the control element must be within the contents of the LABEL element. In this case, the 我想使用f.label方法创建我的表单元素标签,但是 – 我想要将表单元素嵌套在标签内。这可能吗?

– 从W3C –

To associate a label with another control implicitly,the control element must be within the contents of the LABEL element. In this case,the LABEL may only contain one control element. The label itself may be positioned before or after the associated control.

In this example,we implicitly associate two labels with two text input controls:

<form action="..." method="post"> <p>  <label>     First name     <input type="text" name="firstname" />  </label>  <label>     <input type="text" name="lastname" />     Last name  </label>  </p></form>
解决方法 您可以使用块将表单帮助程序嵌套在标签内。以下是使用HAML的示例,但它也适用于ERB。
= form_for your_resource do |f|  = f.label :first_name do    = f.text_fIEld :first_name
总结

以上是内存溢出为你收集整理的html – 嵌入输入f.label(rails表单生成)全部内容,希望文章能够帮你解决html – 嵌入输入f.label(rails表单生成)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1116496.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存