You are here

function theme_registration_state_overview_form in Entity Registration 8.2

Same name and namespace in other branches
  1. 8 includes/registration.forms.inc \theme_registration_state_overview_form()
  2. 7.2 includes/registration.forms.inc \theme_registration_state_overview_form()
  3. 7 includes/registration.forms.inc \theme_registration_state_overview_form()

Theme handler for registration states form.

File

includes/registration.forms.inc, line 1166
Form definitions and callbacks for Registration.

Code

function theme_registration_state_overview_form($variables) {
  $form = $variables['form'];

  // @FIXME
  // TableDrag is now attached with the #tabledrag property of certain render
  // arrays. drupal_add_tabledrag() is now internal and should never be called directly.
  //
  //
  // @see https://www.drupal.org/node/2160571
  // drupal_add_tabledrag('registration-state-admin-settings-table', 'order', 'self', 'registration-state-weight');
  $header = array(
    array(
      'data' => t('Label !required', array(
        '!required' => '<span class="form-required" title="' . t('This field is required.') . '">*</span>',
      )),
    ),
    array(
      'data' => t('Description'),
    ),
    array(
      'data' => t('Default'),
    ),
    array(
      'data' => t('Attended'),
    ),
    array(
      'data' => t('Active'),
    ),
    array(
      'data' => t('Held'),
    ),
    array(
      'data' => t('Show on form'),
    ),
    array(
      'data' => t('Weight'),
    ),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  foreach (\Drupal\Core\Render\Element::children($form['state']) as $key) {
    $row = array();
    foreach (array(
      'label',
      'description',
      'default_state',
      'attended',
      'active',
      'held',
      'show_on_form',
      'weight',
      'delete',
      'export',
    ) as $element) {

      // Since we're rendering these in a table, remove any #title attributes.
      if (!empty($form['state'][$key][$element]['#title'])) {
        unset($form['state'][$key][$element]['#title']);
      }
      $row[] = \Drupal::service("renderer")
        ->render($form['state'][$key][$element]);
    }
    $rows[] = array(
      'class' => array(
        'draggable',
      ),
      'data' => $row,
    );
  }

  // @FIXME
  // theme() has been renamed to _theme() and should NEVER be called directly.
  // Calling _theme() directly can alter the expected output and potentially
  // introduce security issues (see https://www.drupal.org/node/2195739). You
  // should use renderable arrays instead.
  //
  //
  // @see https://www.drupal.org/node/2195739
  // $output = theme('table', array(
  //     'header' => $header,
  //     'rows' => $rows,
  //     'attributes' => array('id' => 'registration-state-admin-settings-table'),
  //   ));
  $output .= drupal_render_children($form);
  return $output;
}