How to store additional_settings value when adding a node? Since storing node type additional_settings is done without the need for calling any other hooks, I quite have a problem to store a simple string from additional_settings on node add form.

After the admin enables a feature on the node type form he/she is offered the following form when adding a node:

$form['MY_MODULE'] = array(
  '#type'         =&gt; 'fieldset',
  '#title'        =&gt; 'Custom String',
  '#collapsible'  =&gt; TRUE,
  '#collapsed'    =&gt; FALSE,
  '#weight'       =&gt; -99,
  '#group'        =&gt; 'additional_settings',
  '#attached'     =&gt; array(
    'js' =&gt; array(
      'vertical-tabs' =&gt; drupal_get_path('module', 'MY_MODULE') . '/MY_MODULE.js',
    ),
  ),
);
$form['MY_MODULE']['MY_MODULE_string'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Enter a string'),
  '#default_value' =&gt; '',
);


I've seen other modules, like comment.module or nodeapi_example.module where they then call hook_node_insert() and I tried that as well. I happily can see my string within dpm($node), but then I'll get a PDOException: SQLSTATE[42S02]: Base table or view not found. Do I have to follow any naming conventions on how to name the table? Or do I have to create it first (where)?:

db_insert('MY_MODULE_string')
-&gt;fields(array(
    'nid' =&gt; $node-&gt;nid,
    'vid' =&gt; $node-&gt;vid,
    'string' =&gt; $node-&gt;MY_MODULE_string,
))
-&gt;execute();
Turned out I simply had to look into nodeapi_example.install to find out about hook_schema() to create a new database table where I then can save my values to. So I created an install file and put the following code inside:

function MY_MODULE_schema() {
  $schema['MY_MODULE_string'] = array(
    'description' =&gt; 'Stores information of extended content.',
    'fields' =&gt; array(
      'nid'    =&gt; array(
        'description' =&gt; 'Node ID that the string is applied to.',
        'type' =&gt; 'int',
        'unsigned' =&gt; TRUE,
        'not null' =&gt; TRUE,
        'default' =&gt; 0,
      ),
      'vid' =&gt; array(
        'description' =&gt; 'Revision ID, as we are tracking strings with node revisions',
        'type' =&gt; 'int',
        'unsigned' =&gt; TRUE,
        'not null' =&gt; TRUE,
        'default' =&gt; 0,
      ),
      'url' =&gt; array(
        'description' =&gt; 'MY MODULE string',
        'type' =&gt; 'varchar',
        'length' =&gt; 19,
        'not null' =&gt; TRUE,
        'default' =&gt; '',
      ),
    ),
    'primary key' =&gt; array('vid'),
    'indexes' =&gt; array(
      'nid'   =&gt; array('nid'),
    ),
  );
  return $schema;
}