You are here

public function ApiTestForm::buildForm in Rocket.Chat 8

Same name and namespace in other branches
  1. 8.2 modules/rocket_chat_api_test/src/Form/ApiTestForm.php \Drupal\rocket_chat_api_test\Form\ApiTestForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

File

modules/rocket_chat_api_test/src/Form/ApiTestForm.php, line 97
Contains \Drupal\rocket_chat_api_test\Form\ApiTestForm.

Class

ApiTestForm
Class RocketChatSettingsForm.

Namespace

Drupal\rocket_chat_api_test\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
  $form['info'] = [
    '#type' => 'item',
    '#title' => $this
      ->t('API Docs'),
    '#markup' => "See the <a href=\"https://rocket.chat/docs/developer-guides/rest-api\">Rocket chat docs on the rest-api</a> for" . " what method's there are and what input it needs.",
  ];
  $form['verb'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('HTTP Verb'),
    '#required' => TRUE,
    '#options' => [
      'GET' => $this
        ->t('Get'),
      'POST' => $this
        ->t('Post'),
    ],
    '#default_value' => 'GET',
  ];
  $form['method'] = [
    '#type' => 'textfield',
    '#description' => $this
      ->t("Rocket chat Method name like 'me'"),
    '#title' => $this
      ->t('Method'),
    '#required' => TRUE,
  ];
  $form['Options'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('JSON encoded options list'),
    '#description' => $this
      ->t("Put a valid JSON string in this textarea."),
    '#required' => FALSE,
  ];
  $form['actions']['#type'] = 'actions';
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Execute!'),
    '#button_type' => 'primary',
  ];
  return $form;
}