You are here

function fel_get_order in Form element layout 7

Determine the render order of a form element.

Returns what order #title, #children and #description should be rendered in, based on #title_display and #description_display.

Parameters

array $element: Form element.

Return value

array An array with the three values 'title', 'children' and 'description' in various orders.

1 call to fel_get_order()
fel_order_output in ./fel.module
Return the output of $parts in configured order.

File

./fel.module, line 339
Reorder #title, #description and #children in forms.

Code

function fel_get_order(array $element) {
  if (!empty($element['#element_order'])) {
    return $element['#element_order'];
  }
  $title_before = (empty($element['#title_display']) or in_array($element['#title_display'], array(
    'before',
    'invisible',
    'inline',
  )));
  $description_before = empty($element['#description_display']) ? FALSE : $element['#description_display'] == 'before';
  if ($title_before) {
    if ($description_before) {
      $order = !empty($element['#title_display']) && $element['#title_display'] == 'inline' ? array(
        'description',
        'title',
        'children',
      ) : array(
        'title',
        'description',
        'children',
      );
    }
    else {
      $order = array(
        'title',
        'children',
        'description',
      );
    }
  }
  else {
    $order = $description_before ? array(
      'description',
      'children',
      'title',
    ) : array(
      'children',
      'title',
      'description',
    );
  }
  return $order;
}