You are here

function state_flow_entity_events_revision in State Machine 7.3

@file Form API related functions used by state_flow_entity and state_flow.

4 string references to 'state_flow_entity_events_revision'
state_flow_entity_form_content_type_render in modules/state_flow_entity/plugins/content_types/state_flow_entity_form.inc
Render the custom content type.
state_flow_entity_handler_area_events_form::render in modules/state_flow_entity/includes/views/state_flow_entity_handler_area_events_form.inc
Render the area.
state_flow_entity_handler_field_events_form::render in modules/state_flow_entity/includes/views/state_flow_entity_handler_field_events_form.inc
Render the field.
state_flow_menu in modules/state_flow/state_flow.module
Implements hook_menu().

File

modules/state_flow_entity/state_flow_entity.forms.inc, line 9
Form API related functions used by state_flow_entity and state_flow.

Code

function state_flow_entity_events_revision($form, &$form_state, $entity_revision, $entity_type = 'node', $new_event = NULL, $form_options = array()) {
  $form_options += array(
    'assemble_page_title' => TRUE,
  );
  $form = _state_flow_entity_events_revision($form, $form_state, $entity_revision, $entity_type, $new_event, $form_options);

  // confirm_form() always calls drupal_set_title() and that is unwanted in some
  // usages of this function.
  if (!empty($form['#page_title'])) {
    drupal_set_title($form['#page_title'], PASS_THROUGH);
  }

  // This user might not have access to any events. If so, do not render any
  // form buttons.
  if (!empty($form['event'])) {
    $yes = t('Update State');
    $no = t('Cancel');
    $path = entity_uri($entity_type, $entity_revision);
    $description = '';
    $name = 'confirm';

    // Prepare cancel link.
    if (isset($_GET['destination'])) {
      $options = drupal_parse_url(urldecode($_GET['destination']));
    }
    elseif (is_array($path)) {
      $options = $path;
    }
    else {
      $options = array(
        'path' => $path,
      );
    }
    $form['#attributes']['class'][] = 'confirmation';
    $form['description'] = array(
      '#markup' => $description,
    );
    $form[$name] = array(
      '#type' => 'hidden',
      '#value' => 1,
    );
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => $yes ? $yes : t('Confirm'),
    );
    $form['actions']['cancel'] = array(
      '#type' => 'link',
      '#title' => $no ? $no : t('Cancel'),
      '#href' => $options['path'],
      '#options' => $options,
    );

    // By default, render the form using theme_confirm_form().
    if (!isset($form['#theme'])) {
      $form['#theme'] = 'confirm_form';
    }
  }
  return $form;
}