I am trying to use the drupal_add_tabledrag in a form table, the dragging is added fine, but dropping is not working

    $entity_ids = range(10,20); // Loading dummy data

    $entities = entity_load('node', $entity_ids);
    $rows = array();

    foreach ($entities as $id => $entity) {
        $rows[$id] = array(
            'data' => array($entity->title),
            'class' => array('draggable', 'entity-weight'),

    $form['settings']['entities'] = array(
        '#tree' => TRUE,
        '#theme' => 'table',
        '#header' => array(t('Title')),
        '#rows' => $rows,
        '#attributes' => array('id' => 'entity_table')

    $form['settings']['title'] = array(
        '#type' => 'textfield',
        '#title' => t('Find entity'),
        '#autocomplete_path' => 'list_bean/autocomplete',

    drupal_add_tabledrag('entity_table', 'order', 'self', 'entity-weight');

    return $form;

I can rearrange items using drag, but I cannot drop the item I drag, it sticks tot he cursor.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.