Hello...

I would like to fill some field on node creation, getting the value from url args.
The purpose is the following : I have node the present some task, and I want a user to create a job node about this task.
What I have done for now is that I have a node reference field on the job node, and when creating the job the user can select a task node.
What I would like to do is to add a link on the task node that links to the job node creation page, and that would fill the node reference value.

I have not found any module that do that, but maybe I have not searched well.

Thanks in advance

Comments

tdimg’s picture

Did you come across the prepopulate module in your search?

goudal’s picture

No... thanks for the hint...

calefilm’s picture

..

tdimg’s picture

and here's another one that makes reference to prepopulate and another module that might fit:

http://drupal.org/project/urlfill
(searched using Automatic field filling from url args and then selecting Project in Filter by type).

goudal’s picture

Thanks, sometimes you don't search with the right terms. But it's nice one.

tdimg’s picture

that's why I searched with the keywords from your title.

calefilm’s picture

This is a question I posted at URL Fill module: http://drupal.org/node/978382

I can't quite grasp URL Fill nor Prepopulate... I can do the simple solution at prepopulate of filling in the title of a node: "This is the title", but beyond that I'm lost.

My objective:

I created a simple "Contact User" tab for each user to display on their profile (I used panels to accomplish this). So that when you click the tab, the user's contact page (node) comes up. I used autopath and URL Alter to accomplish the URL reading: http://mysite.com/user/Mary/mail-to

I added a user reference field. How can I fill in the user reference field with "Mary" ?

What would I do in prepopulate or URL Fill? In URL FILL I go to my field, Enable auto-fill from URL for this field, and see field_mail_to ..... what do I do now?


On node creation page, URL reads: http://mysite.com/user/Mary/mail-to

User reference field: ________

Body

Send

I add: "&field_mail_to=value" to URL (but what can I replace "value" with in order to grab "Mary" from the URL and place it in the field?

Thank you!

calefilm’s picture

I found half of my solution here: http://drupal.org/node/833296 - - subject: "Solved" by Webel.

I found the second half of my solution here http://drupal.org/node/126776 -- #2 by ray007

Again, My object was to grab Mary from the URL and insert into a user reference field in my node edit form.

Note:
-The trick is to set your argument type, once you select one, to Default argument and then select User ID from URL ( http://drupal.org/node/833296 ).
-Because of my argument type: "User relationships: Requester user", I needed to focus on the user as I had created a filter for User Reference--to filter out only a user's friends.
-In fact my view looks very similar to the view that comes with the Relationships module: "user_relationships_browser" view, but needed your adjustment to get things to work right on my form.
-Another critical change I made was to make sure on my content type that my field was a "Select List" and not autocomplete. So now when I applied my argument to this


MY SETTINGS:
create content type
add field - User Reference - Select List
Configure field - View used to select the users: (this is where you go and create a user view)

So now I have to go create a view so that when a user is filling out the node edit form, they are limited to that field's view results.

View - User
Type: HTML list
Fields

Relationships
User Relationships: Requestee user
User Relationships: Requester user
User Relationships: RTID

Fields
(rtid) User relationship types: Plural name
(requestee) User: Name
User relationships: Updated date Added (do not use relationship - excluded)

Filters:
(requester) User relationships: Relationship status = 1 (status: approved)

Arguments:
User relationships: Requestee user
-provide default argument
-User ID from URL

Save

Go back to manage field inside content type
go down to "Advanced - Users that can be referenced (View)" and select your view

Go to default and add this code to your PHP:

return array
(0 => array('uid' => ((int) arg(1))),
);

In my case, I'm grabbing Mary from mysite.com/user/mary so my arguments are going to very. The point is, by adding in this PHP code, Mary will be automatically selected in my select list when a user is editing that particular node (in the process of sending Mary a message)