开发者

Submitting a hash directly with HTML <form> tag

开发者 https://www.devze.com 2022-12-10 03:31 出处:网络
I need to submit a hash of attributes directly from the form tag.Is this possible? <form action=\"/members/1/comments\" method=\"post\">

I need to submit a hash of attributes directly from the form tag. Is this possible?

<form action="/members/1/comments" method="post">
  [some element] {"coordinator\_id"=>"1", "time"=>"1230", "info_link"=>"cnn.com"}
  <submit>Post</submit>
</form>

This hash should arrive as 'comment' => {"coordinator_id"=>开发者_StackOverflow中文版"1", "time"=>"1230", "info_link"=>"cnn.com"}


Almost possible, but not recommended, you should give your values proper names instead, but here is what you asked for:

<form action="/members/1/comments" method="post">
  <input name="comment[coordinator_id]" type="hidden" value="1" />
  <input name="comment[time]" type="hidden" value="1230" />
  <input name="comment[info_link]" type="hidden" value="cnn.com" />
  <submit>Post</submit>
</form>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号