POST 数据拆分时的单独表单参数

发布于 2024-08-11 10:42:52 字数 553 浏览 4 评论 0原文

我正在尝试从表单单独访问日期变量到其他变量。该表单是一个 formattastic 插件表单。我面临的问题是日期是由三部分组成的下拉列表,简单地执行 params[:friend][:born_on] 似乎并没有达到目的,因为它返回 NULL。

这是我的参数输出;

参数:{"commit"=>"创建", "action"=>"创建", "authenticity_token"=>"6+PyuqUNQySe29iEF69PIFvv6DOie5bp4jZAcRva85c=", "controller"=>"朋友", "朋友"=>{"born_on(1i)"=>"1973", "born_on(2i)"=>"3", "born_on(3i)"=>"5", "is_female"=> ;"false", "last_name"=>"史密斯", "first_name"=>"John"}}

我想使用该变量来设置另一个方法; event.happening_on

如有任何帮助,我们将不胜感激 - 谢谢!

I'm trying to access a date variable from a form individually to the other variables. The form is a formtastic plugin form. The issue I am facing is that the date is a three-part dropdown and simply doing params[:friend][:born_on] doesn't seem to be doing the trick as it returns NULL.

Here is my parameters output;

Parameters: {"commit"=>"Create", "action"=>"create", "authenticity_token"=>"6+PyuqUNQySe29iEF69PIFvv6DOie5bp4jZAcRva85c=", "controller"=>"friends", "friend"=>{"born_on(1i)"=>"1973", "born_on(2i)"=>"3", "born_on(3i)"=>"5", "is_female"=>"false", "last_name"=>"Smith", "first_name"=>"John"}}

I want to use the variable to set another method; event.happening_on

Any help is appreciated- thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最美的太阳 2024-08-18 10:42:52

params[:friend][:born_on] 不返回任何内容的原因是因为那不是参数的名称。

您要查找的值似乎是以下之一:params[:friend]["born_on(1i)"]params[:friend]["born_on(2i)" ]params[:friend]["born_on(3i)"]。分别对应于年、月、日。

The reason params[:friend][:born_on] is not returning anything is because that's not the name of the parameter.

It looks like the values you're looking for is one of: params[:friend]["born_on(1i)"], params[:friend]["born_on(2i)"], or params[:friend]["born_on(3i)"]. Which corresponds to what looks like, year, month and day respectively.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文