<?php

namespace Drupal\restaurant_settings\Form;

use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\restaurant\Form\AppForm;

class Addnote extends AppForm {

  /**
   * Returns a unique string identifying the form.
   *
   * The returned ID should be a unique string that can be a valid PHP function
   * name, since it's used in hook implementation names such as
   * hook_form_FORM_ID_alter().
   *
   * @return string
   *   The unique string identifying the form.
   */
  public function getFormId() {
    return 'add_note';
  }

  public function buildForm(array $form, FormStateInterface $form_state)
  {
    
    $form['requirement'] = array(
        '#type' => 'textfield',
        '#required' => true,
        '#title' => $this->t('Requirement'),
    );
    
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => $this->t('Add requirement')
    );

    return $form;
  }

  public function submitForm(array &$form, FormStateInterface $form_state)
  {
      $this->conn->insert('restaurant_requirements')->fields(array('requirement' => $_POST['requirement']))->execute();
      $this->addMessage("Requirement saved")->http_redirect('/admin/restaurant/settings/notes');
  }

}
