You are here

function farm_livestock_weight_action_submit in farmOS 7

Submit handler for farm_livestock_weight_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_livestock/farm_livestock_weight/farm_livestock_weight.module, line 1088
Farm livestock weight module.

Code

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

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

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

  // The action form only includes month, day, and year. If the measurement 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;
  }

  // Add the weight and units fields.
  $context['weight'] = $form_state['values']['weight'];
  $context['units'] = $form_state['values']['units'];

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