You are here

public function EntityInlineForm::isTableDragEnabled in Inline Entity Form 8

Checks whether tabledrag should be enabled for the given table.

Parameters

array $element: The form element representing the IEF table.

Return value

bool TRUE if tabledrag should be enabled, FALSE otherwise.

Overrides InlineFormInterface::isTableDragEnabled

File

src/Form/EntityInlineForm.php, line 152

Class

EntityInlineForm
Generic entity inline form handler.

Namespace

Drupal\inline_entity_form\Form

Code

public function isTableDragEnabled($element) {
  $children = Element::children($element);

  // If there is only one row, disable tabledrag.
  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;
}