1 database_example.module database_example_form_add_submit($form, &$form_state)

Submit handler for 'add entry' form.

Related topics

File

modules/examples/database_example/database_example.module, line 390
Hook implementations for the Database Example module.

Code

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