Project

General

Profile

How to create a link with pre-filled parameters?

Added by clawfrown clawfrown almost 16 years ago

For example I want to make a link to "new issue assigned to me", so that parameter "assigned_to" is pre-filled with "me"..


Replies (4)

RE: How to create a link with pre-filled parameters? - Added by clawfrown clawfrown almost 16 years ago

Unfortunately this code:

<%= link_to l(:label_issue_new), 
:controller => 'issues', 
:project_id => @project, 
:action => 'new', 
:locals => {:assigned_to => User.current}  %>

..does not work..
What i did wrong?

RE: How to create a link with pre-filled parameters? - Added by Eric Davis almost 16 years ago

Link to doesn't understand what the locals definition does. I don't know of any why to link to specific query parameters other than saving a new Query object to the session.

Eric

RE: How to create a link with pre-filled parameters? - Added by clawfrown clawfrown almost 16 years ago

Thanks for reply, Eric.
Unfortunately I haven't got it completely..
Anyway I can experiment a little bit with saving new query object.. (though it can take some time, and I will be grateful if you can explain it a little bit..).
Thanks.

RE: How to create a link with pre-filled parameters? - Added by clawfrown clawfrown almost 16 years ago

Found the way to do that (maybe it will help to somebody):

<%= link_to l(:label_issue_new), :controller => 'issues', :project_id => @project, :action => 'new', :issue =>{:assigned_to_id => User.current.id} %>

By the way.. the condition status_id does not work!!!

<%= link_to l(:label_issue_new), :controller => 'issues', :project_id => 1, :action => 'new', :issue =>{:status_id => 2} %>
    (1-4/4)