/** * Form submission handler. * Adds Inputs to database. * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */ public function submitForm(array &$form, FormStateInterface $form_state) { $name = $form_state->getValue('name'); DataController::addStueck($name); drupal_set_message(t('Play %play has been successfully created.', array('%play' => $name))); return; }
function content() { $url = Url::fromRoute('stueck_datenbank.stueck_add'); $add_link = '<p>' . \Drupal::l(t('Create new play'), $url) . '</p>'; // Table header. $header = array('id' => t('Id'), 'name' => t('Name of Play'), 'operations' => t('Delete')); $rows = array(); foreach (DataController::getAllStuecke() as $id => $content) { // Row with attributes on the row and some of its cells. //Delete Link will be used later. $url = new Url('bd_contact_delete', array('id' => $id)); $rows[] = array('data' => array($id, $content->Stueckname)); } $table = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('id' => 'stueck_datenbank_Overview')); //\Drupal::service('renderer')->render($table, false); return $table; }