You are here

function scald_atom_add_form_add_submit in Scald: Media Management made easy 7

Handles the add step form submission.

1 call to scald_atom_add_form_add_submit()
scald_atom_add_form_options in includes/scald.pages.inc
Options form.

File

includes/scald.pages.inc, line 228
This file contains the various callbacks related to Scald defined pages.

Code

function scald_atom_add_form_add_submit(&$form, &$form_state) {
  $scald = $form_state['scald'];
  $count = 1;
  $atom_count_implemented = FALSE;

  // Allow the source provider to define how many atoms to create
  // and handle differences between upload modules.
  $function = $scald['source'] . '_scald_add_atom_count';
  if (function_exists($function)) {
    $count = $function($form, $form_state);
    $atom_count_implemented = TRUE;
  }
  for ($delta = 0; $delta < $count; $delta++) {
    $atoms[$delta] = new ScaldAtom($scald['type']->type, $scald['source']);
  }

  // Allow the source provider to alter it, filling in defaults value.
  $function = $scald['source'] . '_scald_add_form_fill';
  if (function_exists($function)) {
    if ($atom_count_implemented) {
      $function($atoms, $form, $form_state);
    }
    else {
      $function($atoms[0], $form, $form_state);
    }
    $context = array(
      'form' => $form,
      'form_state' => $form_state,
    );
    drupal_alter('scald_add_form_fill', $atoms, $context);
  }

  // And put it in the form_state.
  $form_state['scald']['atoms'] = $atoms;
}