title: drupal node type hook_insert()
body: <p>Im having some trouble with constructing a drupal custom node type. I created a module, sj_highcharts that will eventually use the highcharts api to deliver a chart of data. The point of this module is to create a node type that will display a form for people to interface with the chart api, store the data in some database tables and then finally output the chart.</p>
  
  <p>The problem is that my hook_insert function or even the hook_validate function isnt being called after the form has been submitted and nothing is getting stored into the database. I have put die statement, to make sure and they don't fire.</p>
  
  <p>The code:</p>
  
  <pre><code>  /*
   * Implementation of hook_node_info().
   */
  function sj_highcharts_node_info() {
    //defining one node type: 'sj highchart'.
    return array(
      'sj_highcharts_element' =&gt; array(
        'name'  =&gt; t('Highchart Element'),
        'module' =&gt; 'sj_highcharts',
        'description' =&gt; t("An element that creates a dynamic chart from specified data."),
        'has_title' =&gt; FALSE,
        'has_body' =&gt; FALSE,
        'locked' =&gt; TRUE,
      )
    );
    //In order to make this an element type, we will have to check the "is element" field in the content type administration page.
  }
  
  /**
   * Implementation of hook_form().
   */
  function sj_highcharts_form($node) {
  
    $type = node_get_types('type', $node);
    $form['delimiter'] = array(
        '#type' =&gt; 'radios',
        '#title' =&gt; t('Data Delimiter'),
        '#description' =&gt; t('The character in which the data is delimited.'),
        '#options' =&gt; array(t('Tab'), t('Space'), t('Comma')),
        '#default_value' =&gt; '',
      );
  
    $form['x_label'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('x-axis label'),
        '#description' =&gt; t('The label to be set and displayed for the x axis.'),
        '#required' =&gt; TRUE,
        '#default_value' =&gt; '',
      );
  
    $form['x_data'] = array(
        '#type' =&gt; 'textarea',
        '#title' =&gt; t('x-axis data'),
        '#description' =&gt; t('The x-axis data to be populated on the chart'),
        '#default_value' =&gt; '',
        '#rows' =&gt; 10,
        '#required' =&gt; TRUE,
      );
  
    $form['y_label'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('x-axis label'),
        '#description' =&gt; t('The label to be set and displayed for the y axis.'),
        '#required' =&gt; TRUE,
        '#default_value' =&gt; '',
      );
  
    $form['y_data'] = array(
        '#type' =&gt; 'textarea',
        '#title' =&gt; t('y-axis data'),
        '#description' =&gt; t('The y-axis data to be populated on the chart'),
        '#default_value' =&gt; '',
        '#rows' =&gt; 10,
        '#required' =&gt; TRUE,
      );
  
    $form['type'] = array(
        '#type' =&gt; 'select',
        '#title' =&gt; t('Select a chart type'),
        '#default_value' =&gt; 'Bar',
        '#description' =&gt; t('Select a chart type to display data.'),
        '#options' =&gt; array(
        '1' =&gt; t('Pie'),
        '2' =&gt; t('Line'),
        '3' =&gt; t('Area'),
        '4' =&gt; t('Scatter'),
        '5' =&gt; t('Bar'),
      ),
    );
  
    $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Create Chart')
    );
  
    return $form;
  }
  
  /**
   * Implentation of hook_validate().
   */
  function sj_highcharts_validate($node) {
    //watchdog('sj_highcharts', 'in validate function');
    die();
  
    if(isset($node-&gt;delimiter)){
  
      //if we are dealing with tab delimited input
      if($node-&gt;delimiter == 'tab'){
  
        //check to see if data sets are the same size
        if(isset($node-&gt;x_data) &amp;&amp; isset($node-&gt;y_data)) {
          if(substr(' ', $node-&gt;x_data) &amp;&amp; substr(' ', $node-&gt;y_data)){
            $xdata_parts = explode('  ', $node-&gt;x_data);
            $ydata_parts = explode('  ', $node-&gt;y_data);
          }
          else{
            form_set_error('delimiter', t('The data delimiter must match the data string entered.'));
          }
  
          if(sizeof($xdata_parts) != sizeof($ydata_parts)){
            form_set_error('x_data', t('The number of data points in each, x and y axes, must match.'));
          }
        }
  
        //change all delimited input to the format we want
        $node-&gt;x_data = str_replace(' ', ',', $node-&gt;x_data);
        $node-&gt;y_data = str_replace(' ', ',', $node-&gt;y_data);
      }
  
      //if we are dealing with space delimited input
      if($node-&gt;delimiter == 'space'){
  
        //check to see if data sets are the same size
        if(isset($node-&gt;x_data) &amp;&amp; isset($node-&gt;y_data)) {
          if(substr(' ', $node-&gt;x_data) &amp;&amp; substr(' ', $node-&gt;y_data)){
            $xdata_parts = explode(' ', $node-&gt;x_data);
            $ydata_parts = explode(' ', $node-&gt;y_data);
          }
          else{
            form_set_error('delimiter', t('The data delimiter must match the data string entered.'));
          }
  
          if(sizeof($xdata_parts) != sizeof($ydata_parts)){
            form_set_error('x_data', t('The number of data points in each, x and y axes, must match.'));
          }
        }
  
        //change all delimited input to the format we want
        $node-&gt;x_data = str_replace(' ', ',', $node-&gt;x_data);
        $node-&gt;y_data = str_replace(' ', ',', $node-&gt;y_data);
      }
  
      //if we are dealing with comma delimited input
      if($node-&gt;delimiter == 'comma'){
  
        //check to see if data sets are the same size
        if(isset($node-&gt;x_data) &amp;&amp; isset($node-&gt;y_data)) {
          if(substr(',', $node-&gt;x_data) &amp;&amp; substr(',', $node-&gt;y_data)){
            $xdata_parts = explode(',', $node-&gt;x_data);
            $ydata_parts = explode(',', $node-&gt;y_data);
          }
          else{
            form_set_error('delimiter', t('The data delimiter must match the data string entered.'));
          }
  
          if(sizeof($xdata_parts) != sizeof($ydata_parts)){
            form_set_error('x_data', t('The number of data points in each, x and y axes, must match.'));
          }
        }
  
        //change all delimited input to the format we want
        $node-&gt;x_data = str_replace(' ', ',', $node-&gt;x_data);
        $node-&gt;y_data = str_replace(' ', ',', $node-&gt;y_data);
  
      }
    }
  }
  
  
  /**
   * Implementation of hook_form_submit().
   */
  function sj_highcharts_insert($node) {
    //watchdog('sj_highcharts', 'in submit function');
    die();
  
    drupal_write_record('highcharts_chart', $node);
  
    $x_data_parts = explode(',', $node-&gt;x_data);
    $axis = 'x';
    for($i = 0;$i &lt; sizeof($x_data_parts);$i++){
      $data_point = $x_data_parts[$i];
  
      //not sure if i should use write_record or not, just know that i need to separate individual data fields
      db_query("INSERT into {higcharts_data} (chart_id, data, axis) VALUES (%d, %d, '%s')", $node-&gt;nid, $data_point, $axis);
    }
  
    $y_data_parts = explode(',', $node-&gt;y_data);
    $axis = 'y';
    for($i = 0;$i &lt; sizeof($y_data_parts);$i++){
      $data_point = $y_data_parts[$i];
  
      //not sure if i should use write_record or not, just know that i need to make sure the chart_id matches other table
      db_query("INSERT into {higcharts_data} (chart_id, data, axis) VALUES (%d, %d, '%s')", $node-&gt;nid, $data_point, $axis);
    }
  }
  </code></pre>
  
  <p>Ive been staring at this for a full workday and cannot find the issue. Any guidance on this would be great. Thanks Brandon</p>