Hiall, I want to give the action of a form an additional parameters but can''t figure out how to do it. My code looks like this <%= start_form_tag :action => ''create'', next_step => true %> <%= render :partial => ''user_form'' %> <%= render :partial => ''community_form'' %> <%= submit_tag "Optional Next Step" %> <%= end_form_tag %> <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> The form_tag should demonstrate what I intend to do. In the corresponding ''create'' action of my controller, I want to redirect_to different locations depending on params[:next_step], but somehow params[:next_step] is never present, and I always end up being redirected to the ''Skip next Step'' action, Any ideas? cheers Martin
Howdy Martin, The first argument of start_form_tag can be a hash of options for url_for- try something like <%= start_form_tag {:action => ''create'', :id=whatever, :param3="community_farm"}, next_step => true %> I hope this helps! -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Martin Gamsjaeger Sent: Wednesday, May 17, 2006 3:35 PM To: Rails Mailing List Subject: [Rails] Form actions with additional parameters Hiall, I want to give the action of a form an additional parameters but can''t figure out how to do it. My code looks like this <%= start_form_tag :action => ''create'', next_step => true %> <%= render :partial => ''user_form'' %> <%= render :partial => ''community_form'' %> <%= submit_tag "Optional Next Step" %> <%= end_form_tag %> <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> The form_tag should demonstrate what I intend to do. In the corresponding ''create'' action of my controller, I want to redirect_to different locations depending on params[:next_step], but somehow params[:next_step] is never present, and I always end up being redirected to the ''Skip next Step'' action, Any ideas? cheers Martin
Hi Martin. Your inclusion of next_step => true should be :next_step => true ie, the option key should be a symbol. The call should be made (I think) as follows. I''m at work and have no ruby here :( start_form_tag :url => { :action => ''create'', :next_step => true } On 5/18/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> > Hiall, > > I want to give the action of a form an additional parameters but can''t > figure out how to do it. My code looks like this > > <%= start_form_tag :action => ''create'', next_step => true %> > <%= render :partial => ''user_form'' %> > <%= render :partial => ''community_form'' %> > <%= submit_tag "Optional Next Step" %> > <%= end_form_tag %> > > <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> > > The form_tag should demonstrate what I intend to do. In the > corresponding ''create'' action of my controller, I want to redirect_to > different locations depending on params[:next_step], but somehow > params[:next_step] is never present, and I always end up being > redirected to the ''Skip next Step'' action, > > Any ideas? > > cheers > Martin > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060518/2df49bf6/attachment.html
Martin Gamsjaeger
2006-May-18 02:45 UTC
[Rails] Re: Form actions with additional parameters
After reading apidoc I am convinced that passing arguments for urls should work with form_tag. I tried the following: <%= start_form_tag({:action => ''create''}, {}, :create_webca => true) %> and it also gives me no parameters for the url ... I can''t figure out what I''m doing wrong Any help VERY much appreciated! Martin On 5/18/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> Hiall, > > I want to give the action of a form an additional parameters but can''t > figure out how to do it. My code looks like this > > <%= start_form_tag :action => ''create'', next_step => true %> > <%= render :partial => ''user_form'' %> > <%= render :partial => ''community_form'' %> > <%= submit_tag "Optional Next Step" %> > <%= end_form_tag %> > > <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> > > The form_tag should demonstrate what I intend to do. In the > corresponding ''create'' action of my controller, I want to redirect_to > different locations depending on params[:next_step], but somehow > params[:next_step] is never present, and I always end up being > redirected to the ''Skip next Step'' action, > > Any ideas? > > cheers > Martin >
Hi Daniel, Thx for the tip, we''re almost getting there :-) Your proposed statement leads to the following html output: <form action="/admin/community/new?url=next_steptrueactioncreate" method="post"> close but not quite there, if only it weren''t so late already where I live :) On 5/18/06, Daniel N <has.sox@gmail.com> wrote:> Hi Martin. > > Your inclusion of next_step => true should be :next_step => true > > ie, the option key should be a symbol. > The call should be made (I think) as follows. I''m at work and have no ruby > here :( > > start_form_tag :url => { :action => ''create'', :next_step => true } > > > On 5/18/06, Martin Gamsjaeger <gamsnjaga@gmail.com > wrote: > > > Hiall, > > I want to give the action of a form an additional parameters but can''t > figure out how to do it. My code looks like this > > <%= start_form_tag :action => ''create'', next_step => true %> > <%= render :partial => ''user_form'' %> > <%= render :partial => ''community_form'' %> > <%= submit_tag "Optional Next Step" %> > <%= end_form_tag %> > > <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> > > The form_tag should demonstrate what I intend to do. In the > corresponding ''create'' action of my controller, I want to redirect_to > different locations depending on params[:next_step], but somehow > params[:next_step] is never present, and I always end up being > redirected to the ''Skip next Step'' action, > > Any ideas? > > cheers > Martin > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Thx for the replies guys! I could swear I tried that before, maybe I didn''t reload properly, back button is too much a habit :) This works (like Daniel suggested the key option should be a symbol) <%= start_form_tag :action => ''create'', :create_webca => true %> Thx for your patience :) cheers Martin On 5/18/06, Daniel Higginbotham <daniel@flyingmachinestudios.com> wrote:> Howdy Martin, > > The first argument of start_form_tag can be a hash of options for url_for- > try something like > > <%= start_form_tag {:action => ''create'', :id=whatever, > :param3="community_farm"}, next_step => true %> > > I hope this helps! > > -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Martin Gamsjaeger > Sent: Wednesday, May 17, 2006 3:35 PM > To: Rails Mailing List > Subject: [Rails] Form actions with additional parameters > > Hiall, > > I want to give the action of a form an additional parameters but can''t > figure out how to do it. My code looks like this > > <%= start_form_tag :action => ''create'', next_step => true %> > <%= render :partial => ''user_form'' %> > <%= render :partial => ''community_form'' %> > <%= submit_tag "Optional Next Step" %> > <%= end_form_tag %> > > <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> > > The form_tag should demonstrate what I intend to do. In the > corresponding ''create'' action of my controller, I want to redirect_to > different locations depending on params[:next_step], but somehow > params[:next_step] is never present, and I always end up being > redirected to the ''Skip next Step'' action, > > Any ideas? > > cheers > Martin > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Me again :) Funny enough, this doesn''t give me the expected parameter <%= button_to ''Skip next step'', :action => ''create'', :create_webca => false %> Yes, I got the one with the back button right :) Now I''m actually wondering if it wasn''t about the back button in the beginning. ??? On 5/18/06, Martin Gamsjaeger <gamsnjaga@gmail.com> wrote:> Thx for the replies guys! I could swear I tried that before, maybe I > didn''t reload properly, back button is too much a habit :) > > This works (like Daniel suggested the key option should be a symbol) > > <%= start_form_tag :action => ''create'', :create_webca => true %> > > Thx for your patience :) > > cheers > Martin > > On 5/18/06, Daniel Higginbotham <daniel@flyingmachinestudios.com> wrote: > > Howdy Martin, > > > > The first argument of start_form_tag can be a hash of options for url_for- > > try something like > > > > <%= start_form_tag {:action => ''create'', :id=whatever, > > :param3="community_farm"}, next_step => true %> > > > > I hope this helps! > > > > -----Original Message----- > > From: rails-bounces@lists.rubyonrails.org > > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Martin Gamsjaeger > > Sent: Wednesday, May 17, 2006 3:35 PM > > To: Rails Mailing List > > Subject: [Rails] Form actions with additional parameters > > > > Hiall, > > > > I want to give the action of a form an additional parameters but can''t > > figure out how to do it. My code looks like this > > > > <%= start_form_tag :action => ''create'', next_step => true %> > > <%= render :partial => ''user_form'' %> > > <%= render :partial => ''community_form'' %> > > <%= submit_tag "Optional Next Step" %> > > <%= end_form_tag %> > > > > <%= button_to ''Skip Next Step'', :action => ''create'', next_step => false %> > > > > The form_tag should demonstrate what I intend to do. In the > > corresponding ''create'' action of my controller, I want to redirect_to > > different locations depending on params[:next_step], but somehow > > params[:next_step] is never present, and I always end up being > > redirected to the ''Skip next Step'' action, > > > > Any ideas? > > > > cheers > > Martin > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >