You are here

function dbtng_example_form_add_submit in Examples for Developers 7

Submit handler for 'add entry' form.

Related topics

File

dbtng_example/dbtng_example.module, line 505
This is an example outlining how a module can make use of the new DBTNG database API in Drupal 7.

Code

function dbtng_example_form_add_submit($form, &$form_state) {
  global $user;

  // Save the submitted entry.
  $entry = array(
    'name' => $form_state['values']['name'],
    'surname' => $form_state['values']['surname'],
    'age' => $form_state['values']['age'],
    'uid' => $user->uid,
  );
  $return = dbtng_example_entry_insert($entry);
  if ($return) {
    drupal_set_message(t("Created entry @entry", array(
      '@entry' => print_r($entry, TRUE),
    )));
  }
}