You are here

function inline_entity_form_has_tabledrag in Inline Entity Form 7

Returns whether tabledrag should be enabled for the given table.

Parameters

$element: The form element representing the IEF table.

Return value

TRUE if tabledrag should be enabled, FALSE otherwise.

1 call to inline_entity_form_has_tabledrag()
theme_inline_entity_form_entity_table in ./inline_entity_form.module
Themes the table showing existing entity references in the widget.

File

./inline_entity_form.module, line 1765
Provides a widget for inline management (creation, modification, removal) of referenced entities. The primary use case is the parent -> children one (for example, order -> line items), where the child entities are never managed outside the…

Code

function inline_entity_form_has_tabledrag($element) {
  $children = element_children($element);

  // If there is only one row, disable tabletrag.
  if (count($children) == 1) {
    return FALSE;
  }

  // If one of the rows is in form context, disable tabledrag.
  foreach ($children as $key) {
    if (!empty($element[$key]['form'])) {
      return FALSE;
    }
  }
  return TRUE;
}