Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. foreach ($form_state->getValues(['mytable','rows']) as $tablerow) {
  2.  
  3. $tablerow['label']
  4.  
  5. foreach ($entities as $id => $entity) {
  6. // TableDrag: Mark the table row as draggable.
  7. $form['mytable'][$id]['#attributes']['class'][] = 'draggable';
  8. // TableDrag: Sort the table row according to its existing/configured weight.
  9. $form['mytable'][$id]['#weight'] = $entity->get('weight');
  10.  
  11. // Some table columns containing raw markup.
  12. $form['mytable'][$id]['label'] = array(
  13. '#plain_text' => $entity->label(),
  14. );
  15. $form['mytable'][$id]['id'] = array(
  16. '#plain_text' => $entity->id(),
  17. );
  18.  
  19. // TableDrag: Weight column element.
  20. $form['mytable'][$id]['weight'] = array(
  21. '#type' => 'weight',
  22. '#title' => t('Weight for @title', array('@title' => $entity->label())),
  23. '#title_display' => 'invisible',
  24. '#default_value' => $entity->get('weight'),
  25. // Classify the weight element for #tabledrag.
  26. '#attributes' => array('class' => array('mytable-order-weight')),
  27. );
  28.  
  29. // Operations (dropbutton) column.
  30. $form['mytable'][$id]['operations'] = array(
  31. '#type' => 'operations',
  32. '#links' => array(),
  33. );
  34. $form['mytable'][$id]['operations']['#links']['edit'] = array(
  35. 'title' => t('Edit'),
  36. 'url' => Url::fromRoute('mymodule.manage_edit', array('id' => $id)),
  37. );
  38. $form['mytable'][$id]['operations']['#links']['delete'] = array(
  39. 'title' => t('Delete'),
  40. 'url' => Url::fromRoute('mymodule.manage_delete', array('id' => $id)),
  41. );
  42. }
  43.  
  44. $form['mytable'][$id]['label'] = array(
  45. //'#plain_text' => $entity->ref,
  46. '#type' => 'number',
  47. '#title' => "",
  48. '#default_value' => $entity->ref,
  49. '#disabled' => TRUE,
  50. '#access' => FALSE,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement