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 8405489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:51:53+00:00 2026-06-09T22:51:53+00:00

Ok, so i am trying to get the value from one textfield and pass

  • 0

Ok, so i am trying to get the value from one textfield and pass it to two different methods in a viewController when the user clicks on either the “Add” button or “search” button (so if user presses search button it geoes to search method and if user clicks add button it goes to add method), so far this code does the trick but i dont like that there has to be two text fields, should i maybe use button_to’s? and if so how would that look? Thx

  <p><%= form_tag :controller => 'projects', :action => 'search', :method => 'get' do %>

  <%= text_field_tag :search, params[:search] %>
  <%= submit_tag "search" %>
  <%= link_to_function "Clear", "$('search_field').clear()" %>
  <% end %>
  </p>

  <p><%= form_tag :controller => 'projects', :action => 'add_project_to_user' do %>
  <%= text_field_tag :text, params[:text] %>
  <%= submit_tag "Add" %>
  <%= link_to_function "Clear", "$('search_field').clear()" %>
  <% end %>
  </p>
  • 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-06-09T22:51:54+00:00Added an answer on June 9, 2026 at 10:51 pm

    Thanks for the clarifications. The limitation is with HTML, not Rails: A form can have only one action. That is: one controller & action.

    There are few options. You can branch your behavior within your controller. Have one action that handles either Search or Add, depending on which button is clicked (yes, you can have multiple buttons within the form; there is an old railscasts (Episode 38) on this. However this is rather clunky.

    Another option is to use JavaScript to set the action on the form in response to the button click.

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

Sidebar

Related Questions

Im trying to get the value from BrandID in one table and add it
Im trying to work out how to get the value from one setting in
i am trying to get the value from my methods and display it in
I'm trying to get the MIN value from both tables (one return value). Following
I'm trying to retrieve a boolean value from one of two member functions. I
I'm trying to get a value from one of my database values, which will
I am trying to pass a selected checkbox value from one page to another
Hi I am trying to pass a value from one file to another file
I'm new to php and i'm trying to pass a value from one to
I am trying to get value from passwordbox for developing a simple login functionality,

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.