I am new to drupal 8. I have created a form listing in admin.Now i want to add three or more links for operation(Edit/Delete/Suspend) in single TD columns. Can anyone let me know how to do this? I tried by concatenation two links but did not work. I am creating links as below.
$query = \Drupal::database()->select('vacations', 'v'); $query->fields('v'); $table_sort = $query->extend('Drupal\Core\Database\Query\TableSortExtender')->orderByHeader($header); $pager = $table_sort->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit(10); //$results = $query->execute()->fetchAll(); $results = $pager->execute(); // Initialize an empty array $output = array(); // Next, loop through the $results array foreach ($results as $key => $result) { $approve_link = Link::fromTextAndUrl(t('Approve'), Url::fromRoute('vacation_forms.operations', ['ID' => $result->id, 'action' => 'approve']))->toString(); $reject_link = Link::fromTextAndUrl(t('Reject'), Url::fromRoute('vacation_forms.operations', ['ID' => $result->id, 'action' => 'reject']))->toString(); $newLink = $approve_link; // this works //$newLink = $approve_link . "|" . $reject_link; //this does not work it shows plain html in table columns $output[$result->id] = [ //'id' => $result->id, 'employee_name' => $result->employee_name, 'employee_email' => $result->employee_email, 'vacation_start_date' => $result->vacation_start_date, 'vacation_end_date' => $result->vacation_end_date, 'leave_days' => $result->leave_days, 'status' => $result->status, 'operations' => $newLink, ]; } $form['table'] = [ '#type' => 'tableselect', '#header' => $header, '#options' => $output, '#empty' => t('No users found'), ];
I am using Drupal 8.