Rails 选择助手中的 :include_blank 和 :prompt 有什么区别? [英] What's the difference between :include_blank and :prompt in the Rails select helper?

查看:31
本文介绍了Rails 选择助手中的 :include_blank 和 :prompt 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Rails 文档中,前两个select 助手的列出选项是 :include_blank:prompt.我刚刚意识到我在我的代码中同时使用了两者,但它们似乎可以互换.谁能解释一下区别?通过阅读文档,我不清楚.

In the Rails docs, the first two listed options for the select helper are :include_blank and :prompt. I've just realized that I'm using both in my code, but they seem to be interchangeable. Can anyone explain the difference? It's not clear to me from reading the docs.

推荐答案

主要区别在于:

include_blank: true

将呈现一个空白选项,但

will render a blank option but

prompt: true

将执行

I18n.translate('helpers.select.prompt', :default => 'Please select')

这篇关于Rails 选择助手中的 :include_blank 和 :prompt 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆