Trying to programmatically create a new node type, I do:

$values['name'] = 'node type test';
$values['type'] = 'node_type_test';
$values['description'] = 'my description.';
$values['comment'] = 0;
drupal_execute('node_type_form', $values);

but I get:

warning: call_user_func_array(): First argumented is expected to be a valid 
callback, 'node_type_form' was given in /includes/form.inc on line 181.

I am puzzle because the function does exist in modules/node/content_types.inc:
function node_type_form($type = NULL) {

Comments

chx’s picture

Status: Active » Closed (won't fix)

yes but you need to include that inc.

beginner’s picture

Status: Closed (won't fix) » Active

with Drupal 5, we are supposed to be able to programmatically submit forms using drupal_execute(), and if you cannot do so, it is a bug.
I just don't understand the reason for this particular bug, yet.

chx’s picture

Status: Active » Closed (won't fix)

the form you are submitting to is not included automatically on every page load, you need to do that by hand.

beginner’s picture

Status: Closed (won't fix) » Active

So?
How do I programmatically submit a form to create a new node type?

beginner’s picture

Status: Active » Closed (won't fix)

Oh! I see what you mean... let me try...

beginner’s picture

Status: Closed (won't fix) » Closed (works as designed)

Now that you have shown me, TWICE, the solution, I find it's obvious and I kick myself for not having thought about it myself!!

I apologize for being so thick-headed!

The missing line:

include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';