I'm using CCK to create an example content type.

The new submission page is located here...
/node/add/content-example

And the form inputs are referenced like this...
input type="text" name="edit[example][attribute1]" id="edit-example-attribute1"

How do I post variables so that they will pre-populate the form values?

Neither of these are working...
/node/add/content-example?edit[example][attribute1]=test
/node/add/content-example?edit-example-attribute1=test

Previously, I created a custom module (not using CCK) and was able to pass vars like this...
/node/4/edit?edit[attribute1]=test

Come someone shed a little light on this?

Comments

creazion_dev’s picture

Hi savnet,

take a look at the prepopulate module.

---------------------------------------------
last projects: www.happy-faces.de - www.3p-consulting.com

geohelper’s picture

I'm surprised that CCK doesn't have prepopulating built in, but the prepopulate module did not work either.

Specifically, I'm trying to pass the latitude and longitude variables into a CCK-based node that uses the location module.

Here is the url structure that I'm trying...

/node/add/content-example?edit[example][latitude]=111&edit[example][longitude]=222

geohelper’s picture

Updated url structure (broken down)...

/node/add/content-example?
edit[title]=Test
&edit[taxonomy][4]=14
&edit[example][latitude]=111
&edit[example][longitude]=222

The title variable is prepopulating in the form now that I've enabaled the prepopulate modules (thanks).

But the taxonomy select box is not being set and neither are the latitude/longitude variables.

My goal is to build a map that allows users to add nodes based on location. All this should be very simple, but it is critical that the lat/lon variables can be passed to the /node/add page. It would also help to be able to pass the taxonomy variable.

This is the one thing stopping me from moving forward w/ the cck/location modules and I'd rather not have to develop a new module the old-school way.

Has anyone else had this problem?

ericfoy’s picture

Yes, I am having the exact same experience. the "edit[title]" works, but none of the cck fields will prepopulate...

can anyone help?

ericfoy’s picture

I have come up with a hack that now has several of the cck fields prepopulating from the URL.

It's pretty ugly, and it relies on partial knowledge of the cck data structure (this dependency is not cool), but, hey, it works.

Anyone let me know if you're interested.

-eric

robert.redl@easytouch.cc’s picture

Yes I would have interest in this magic thing.
I qould like to prepoulate an ITIL application I built with CCK,
where an Incident gets a button to create a problemticket that is connected to the Incident
by fpre-filling the Autocomplete CCK field.

Please tell us how you hacked this thing.

eafarris’s picture

Please give the CVS version of prepopulate.module a try. Recent patches have really improved this module. I'm now using it with CCK on my site.

geohelper’s picture

I just tried it and still unable to post location variables...

The URL structure below does not work when using the image and location modules, but my other custom module is able to have variables posted in the first format (not using location module).

http://community.vlogmap.org/node/add/image?edit[location][latitude]=111
http://community.vlogmap.org/node/add/image?edit-location-latitude=111

Any ideas?

fsa3’s picture

Did anyone ever get anywhere with this issue... having a very similiar issue where:

http://drupal.mysite.com/?q=node/add/project&edit[title]=Test

works, but

http://drupal.mysite.com/?q=node/add/project&edit[body]=Test

does not.

harrisou’s picture

This would seem like a very useful module...if it were to work correctly.

Any ideas?

bsuttis’s picture

I've been able to populate a CCK field like so:

<a href="javascript:location.href='http://localhost/k/node/add/web-site-entry?edit[field_web_site_link][0][url]='+encodeURIComponent(location.href)+'&edit[title]='+encodeURIComponent(document.title)">post it</a>

Basically, I used the exact name of the CCK form field in the submit form field_web_site_link[0][url], added brackets around the field's name like so, [field_web_site_link][0][url] and it works, I haven't done extensive testing, but it's populating for me in FF.

dantina’s picture

Would the prepopulate.module work for populating a CCK text field (Text | Text field) with information from database table based on user selection (i.e. if a user selects Product ID, the product description text field is populated automatically) on an input form.

I found I was able to populating a Select list field (Text | Select List) field but I cannot seem to update the text field (using the concept outlined here http://blue.live4all.co.il/~mooffie/cms/node/15), by placing some PHP code in the allowed values section for the field.

andrew7’s picture

But it seems to severely lack proper documentation, that's all.

You all know what to do for the title field:

?edit[title]=Just put some title here...

Other fields are tricky because you need to use the exact name, and also treat the input as an array:

?edit[field_name][0][value]=here goes the prepopulate value

An example: I have a CCK content type called "group" which has a zip code field. This is how I pre-populate from the URL:

?edit[field_zip][0][value]=10100

Cheers,
Keysar.

jarea’s picture

If the field is part of a CCK field group, the edit string needs to look like:

edit[group_name][field_name][0][value]=value

for example:

edit[group_individuals_name][field_name_first][0][value]=Andrew

Also, if you want to prepopulate a node referenced node, the string would look like

edit[field_name][nids]=Node ID of the node referenced node

for example:

edit[field_entity_name][nids]=141

aaustin’s picture

I am not sure I would have thought of trying it with the CCK group name.

You completely save me.

Thanks so much!

superbuller’s picture

Hi you seem to know a thing or to about prepopulate, so heres my question.

Im trying to create a link, in a form, that takes the data from a cck field, and uses it in the link url, so that the url will prepopulate a field in a new node.

here is how my url looks right now, but this isnt working, and i have no idea how to move forward from here:

http://www.example.dk/node/add/content_type?edit[title]=[field_e1-raw]

any help would be apreciatet.

geohelper’s picture

Thanks, here is an example for prepopulating the location module's latitude/longitude (and avoid using the gmap module)...

/node/add/content-example?edit[title]=Test&edit[locations][0][latitude]=1.234&edit[locations][0][longitude]=5.678

internets’s picture

Is there anyway to utilize this module to populate CCK fields with user profile data created with the content_profile module?

It appears to be only for static data passed through the URL, it seems to work well for that purpose.

Any suggestions on how to pass user profile data (in my case a use profile content type "contact_details") specifically location field data assigned to the contact details content type.

Thanks for any suggestions.