1 dbtng_example.module dbtng_example_form_add_submit($form, &$form_state)

Submit handler for 'add entry' form.

Related topics

File

modules/examples/dbtng_example/dbtng_example.module, line 421
This is an example outlining how a module can make use of the DBTNG database API in Backdrop.

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) {
    backdrop_set_message(t("Created entry @entry", array('@entry' => print_r($entry, TRUE))));
  }
}