Gavin
Gavin

Reputation: 4333

Submitting a hash directly with HTML <form> tag

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"=>"1", "time"=>"1230", "info_link"=>"cnn.com"}

Upvotes: 0

Views: 4635

Answers (1)

soulmerge
soulmerge

Reputation: 75724

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>

Upvotes: 1

Related Questions