I searched extensively and didn't find a clear answer on this.

I created a new content type, "my_type", with additional cck fields. I want to create a new node inside php code programmatically. If I use drupal_execute(), what form id should I use?

I used drupal_execute() on a node type that was defined by a module. This user-defined type has an associated form, I used that form id, and it worked in that case. But I am replacing the module-defined type with cck content type. Now I don't have a specific form-id for this new type anymore.

thanks for any help.

Comments

Clarkmatic’s picture

I'm attempting to do the same thing so that I can import 'regions' through an XML file:

$region_node = array('type' => 'ftm_region');
$region_values = array(
	'title' => $new_region_key,
	'field_region_type[nids]' => 7,  // where 7 is an existing region_type node,
	'field_country[nids]' => 22, // where 22 is an existing country node,
);
			
$result = drupal_execute('ftm_region_node_form', $region_values, $region_node);

But I get an error message stated: "Country : This post can't be referenced."

Is this the correct way to go about programmatically create a new CCK node?

Thanks for any help.

Clarkmatic’s picture

I figured out an answer that seems to work well.

Take tips from http://www.lullabot.com/articles/moving-cck-field-changes-from-dev-to-live and use the macro function in the Devel module to record an example of creating the custom type you want to create and then use the macro output in your code.