You are here

function farm_movement_asset_move_action_submit in farmOS 7

Submit handler for farm_movement_asset_move action configuration form.

Parameters

array $form: The form array.

array $form_state: The form state array.

Return value

array Returns an array that will end up in the action's context.

File

modules/farm/farm_movement/farm_movement.location.inc, line 846
Code for managing the location of assets with movement logs.

Code

function farm_movement_asset_move_action_submit(array $form, array $form_state) {

  // Start to build the context array.
  $context = array();

  // Load the areas.
  $context['areas'] = farm_term_parse_names($form_state['values']['areas'], 'farm_areas', TRUE);

  // Convert the date to a timestamp.
  $timestamp = strtotime($form_state['values']['date']);

  // The action form only includes month, day, and year. If the movement is
  // today, then we assume that the current time should also be included.
  if (date('Ymd', $timestamp) == date('Ymd', REQUEST_TIME)) {
    $context['timestamp'] = REQUEST_TIME;
  }
  else {
    $context['timestamp'] = $timestamp;
  }

  // Copy the "done" value as a boolean.
  $context['done'] = !empty($form_state['values']['done']) ? TRUE : FALSE;

  // Return the context array.
  return $context;
}