Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3844822
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:08:57+00:00 2026-05-19T16:08:57+00:00

I have a form_for I’m making in my view helper that is going to

  • 0

I have a form_for I’m making in my view helper that is going to let one user promote another user from a group.

  def promote_button_for(group, user)
    membership = group.get_membership( user )
    form_for membership, :url => group_membership_path( group, membership ) do |f|
      f.hidden_field :group_creator
      hidden_field_tag 'test', '1'
      f.submit( "Promote", :onclick => "return confirm(\"Are you sure you want to promote #{user.email} to an officer?\")" )
    end
  end

When I submit the form via the button, I don’t seem to get any of the hidden field parameters sending to the controller.

Started POST "/groups/1/memberships/6" for 127.0.0.1 at 2011-02-01 01:45:32 -0600
  Processing by MembershipsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"VQl/rVX8OVOETv2HE7KtopUc3B19ShoMkUhjJwNlaZs=", "commit"=>"Promote", "group_id"=>"1", "id"=>"6"}

The generated Html looks like:

<form accept-charset="UTF-8" action="/groups/1/memberships/6" class="edit_membership" id="edit_membership_6" method="post">
   <div style="margin:0;padding:0;display:inline">
      <input name="utf8" type="hidden" value="&#x2713;" />
      <input name="_method" type="hidden" value="put" />
      <input name="authenticity_token" type="hidden" value="VQl/rVX8OVOETv2HE7KtopUc3B19ShoMkUhjJwNlaZs=" />
   </div>
   <input id="membership_submit" name="commit" onclick="return confirm(&quot;Are you sure you want to promote kquiring@gmail.com to an officer?&quot;)" type="submit" value="Promote" />
</form>

Any help would be greatly appreciated,

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:08:57+00:00Added an answer on May 19, 2026 at 4:08 pm

    You are having this problem because the form_for object is only seeing the string that is generated by the last f.submit tag, while everything else between the form_for and the f.submit is lost.

    In this case, the form_for tag does not manipulate the view directly, as it is basically just a string that is returned from the promote_button_for method.

    The answer is that you just need to chain the generated tags together, like this:

    def promote_button_for(group, user)
      membership = group.get_membership( user )
      form_for membership, :url => group_membership_path( group, membership ) do |f|
        f.hidden_field(:group_creator) << \
        hidden_field_tag('test', '1') << \
        f.submit( "Promote", :onclick => "return confirm(\"Are you sure you want to promote #{user.email} to an officer?\")" )
      end
    end
    

    Notice the << \, which concatenates all the generated strings together and returns them to form_for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form <% form_for(@player) do |f| %> that displays the user's password
I have a form_for(@task) do |f| . Each task belongs to a group. I
Say I have a form_for with a select menu to assign a User on
Let's say I have a form for adding/editing products (with field 'user' being a
Specifically, I have a form for creating a User . One of the fields
I have a form (for A) that redirects to another form (form B). When
I have this form in a partial: <%= form_for current_user.relationships.build(:followed_id => @profile.user.id) do |f|
I have a form for that a user fills out and submits. Once submitted
I have a form, with a submit button: <% form_for(@personalentry) do |f| %> <%=
I have a simple form for generating reports that I am adding a jqueryUI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.