You are here

public function TwilioAdminTestForm::buildForm in Twilio 8

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

src/Form/TwilioAdminTestForm.php, line 49

Class

TwilioAdminTestForm
Form to send test SMS messages.

Namespace

Drupal\twilio\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['country'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Country code'),
    '#options' => TwilioController::countryDialCodes(FALSE),
  ];
  $form['number'] = [
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => $this
      ->t('Phone Number'),
    '#description' => $this
      ->t('The number to send your message to. Include all numbers except the country code'),
  ];
  $form['message'] = [
    '#type' => 'textarea',
    '#required' => TRUE,
    '#title' => $this
      ->t('Message'),
    '#description' => $this
      ->t("The body of your SMS message."),
  ];
  $form['mediaUrl'] = [
    '#type' => 'textfield',
    '#required' => FALSE,
    '#title' => $this
      ->t('Media URL (MMS)'),
    '#description' => $this
      ->t('A publicly accessible URL to a media file such as a png, jpg, gif, etc. (e.g. http://something.com/photo.jpg)'),
  ];
  $form['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Send SMS'),
  ];
  return $form;
}