You are here

function theme_inline_conditions_table in Inline Conditions 7

Returns HTML for an individual inline conditions widget.

Parameters

array $variables: An associative array containing:

  • element: A render element representing the widget.

Return value

string The HTML to be rendered.

1 theme call to theme_inline_conditions_table()
inline_conditions_field_widget_form in ./inline_conditions.field.inc
Implements hook_field_widget_form().

File

./inline_conditions.module, line 55
Extends Drupal 7 with a new field type to manage rules conditions directly from a field.

Code

function theme_inline_conditions_table($variables) {
  $element = $variables['element'];

  // Initialize the variable which will store our table rows.
  foreach (element_children($element) as $key) {
    if (is_numeric($key) && $key > 0) {

      // Render the logical operator form element and pop it into the upper row.
      $rows[] = array(
        'data' => array(
          array(
            'data' => $element[$key]['condition_logic_operator'],
            'colspan' => 4,
          ),
        ),
      );
    }
    if (is_numeric($key)) {
      $rows[] = array(
        'data' => array(
          // Column: "Apply to".
          array(
            'data' => $element[$key]['condition_name'],
          ),
          // Column: "Settings".
          array(
            'data' => $element[$key]['condition_settings'],
          ),
          // Column: "Negate".
          array(
            'data' => $element[$key]['condition_negate'],
          ),
          // Column: "Remove".
          array(
            'data' => $element[$key]['remove_condition'],
          ),
        ),
      );
    }
  }

  // Render action buttons.
  $rows[] = array(
    'data' => array(
      array(
        'data' => array(
          $element['and_condition'],
          $element['or_condition'],
        ),
        'colspan' => 4,
      ),
    ),
  );
  return theme('table', array(
    'header' => array(
      t('Apply to'),
      t('Settings'),
      t('Negate'),
      t('Remove'),
    ),
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'inline-conditions-table',
      ),
    ),
    'caption' => isset($element['#caption']) ? $element['#caption'] : NULL,
  ));
}