Forum: Ruby on Rails forms and controller scope

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Adam A. (Guest)
on 2009-01-23 11:04
Is it possible to pass predefined arguments along with a form with
form_for? i.e. an id etc?

I have a task model with usual title, completed(bool), duedate and a
foreign key field called project_id (a project has many tasks). On one
view i want to have an "express add task" form i.e. there is only one
field to fill in for the title. The rest of the attributes I want to set
to some default values. The problem is this form will be sent to a
dffierent controller.

As the user only submits a title ill also need the project_id which is
known is available in the view...is there anyway i can pass this along
with the form?
Mark Reginald J. (Guest)
on 2009-01-23 11:39
(Received via mailing list)
Adam A. wrote:
> As the user only submits a title ill also need the project_id which is
> known is available in the view...is there anyway i can pass this along
> with the form?

You can put some fixed parameters in the path part of the form's
action URL, which will be extracted by the Rails routes you define,
plus put some more parameters in hidden form fields.

--
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
Adam A. (Guest)
on 2009-01-23 12:59
thanks very much for that. I went away and researched teh api more about
hidden fields. I did try them out a while back but got an error and
thought i was heading down the wrong path but you confirmed i was indeed
looking in the right area.

thank you once again
This topic is locked and can not be replied to.