programmatically creating a new node type
beginner - September 7, 2006 - 13:57
| Project: | Drupal |
| Version: | x.y.z |
| Component: | forms system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | by design |
Jump to:
Description
Trying to programmatically create a new node type, I do:
<?php
$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:
<?php
function node_type_form($type = NULL) {
?>
#1
yes but you need to include that inc.
#2
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.
#3
the form you are submitting to is not included automatically on every page load, you need to do that by hand.
#4
So?
How do I programmatically submit a form to create a new node type?
#5
Oh! I see what you mean... let me try...
#6
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:
<?phpinclude_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
?>