You are here

public function MobileNumberTfa::getForm in Mobile Number 7

Form callback.

Overrides TfaValidationPluginInterface::getForm

File

src/MobileNumberTfa.php, line 74
Contains MobileNumberTfa.

Class

MobileNumberTfa
Class MobileNumberTfa is a validation and sending plugin for TFA.

Code

public function getForm(array $form, array &$form_state) {
  $numberClue = str_pad(substr($this->mobileNumber->localNumber, -3, 3), strlen($this->mobileNumber->localNumber), 'X', STR_PAD_LEFT);
  $numberClue = substr_replace($numberClue, '-', 3, 0);
  $form['code'] = array(
    '#type' => 'textfield',
    '#title' => t('Verification Code'),
    '#required' => TRUE,
    '#description' => t('A verification code was sent to %clue. Enter the @length-character code sent to your device.', array(
      '@length' => $this->codeLength,
      '%clue' => $numberClue,
    )),
  );
  $form['actions']['#type'] = 'actions';

  // @todo optionally report on when code was sent/delivered.
  $form['actions']['login'] = array(
    '#type' => 'submit',
    '#value' => t('Verify'),
  );
  $form['actions']['resend'] = array(
    '#type' => 'submit',
    '#value' => t('Resend'),
    '#submit' => array(
      'tfa_form_submit',
    ),
    '#limit_validation_errors' => array(),
  );
  return $form;
}