You are here

function activity_create_form_submit in Activity 7

Form submit callback to create the new ActivityActionHandler.

File

./activity.admin.inc, line 59
activity.admin.inc Contains administrative forms for activity.module

Code

function activity_create_form_submit($form, &$form_state) {

  // Save it once to get the aid.
  $aid = actions_save('activity_record', 'activity', array(), $form_state['values']['label']);

  // Now save the aid away to the parameters.
  $handler = activity_load_handler($form_state['values']['hook']);
  actions_save('activity_record', 'activity', array(
    'aid' => $aid,
    'templates' => array(),
    'options' => ActivityActionHandler::defaultOptions($handler
      ->optionDefinition()),
  ), $form_state['values']['label'], $aid);

  // Write to the trigger assignments.
  $record = array(
    'hook' => $form_state['values']['hook'],
    'weight' => 0,
    'aid' => $aid,
  );
  drupal_write_record('trigger_assignments', $record);
  $form_state['redirect'] = array(
    'admin/structure/activity/configure/' . $aid,
    array(
      'query' => array(
        'new' => 1,
      ),
    ),
  );
}