protected function SendToPhoneForm::getForm in SMS Framework 8
Builds the form array.
1 call to SendToPhoneForm::getForm()
- SendToPhoneForm::buildForm in modules/
sms_sendtophone/ src/ Form/ SendToPhoneForm.php - Form constructor.
File
- modules/
sms_sendtophone/ src/ Form/ SendToPhoneForm.php, line 108
Class
- SendToPhoneForm
- Default controller for the sms_sendtophone module.
Namespace
Drupal\sms_sendtophone\FormCode
protected function getForm(array $form, FormStateInterface $form_state, $type = NULL, $extra = NULL) {
switch ($type) {
case 'cck':
case 'field':
case 'inline':
$form['message'] = [
'#type' => 'value',
'#value' => $this
->getRequest()
->get('text'),
];
$form['message_preview'] = [
'#type' => 'item',
'#markup' => '<p class="sms-sendtophone--message-preview">' . $this
->getRequest()
->get('text') . '</p>',
'#title' => t('Message preview'),
];
break;
case 'node':
if (is_numeric($extra)) {
$node = Node::load($extra);
$form['message_display'] = [
'#type' => 'textarea',
'#title' => t('Message preview'),
'#description' => t('This URL will be sent to the phone.'),
'#cols' => 35,
'#rows' => 2,
'#attributes' => [
'disabled' => TRUE,
],
'#default_value' => $node
->toUrl()
->setAbsolute()
->toString(),
];
$form['message'] = [
'#type' => 'value',
'#value' => $node
->toUrl()
->setAbsolute()
->toString(),
];
}
break;
}
$form['number'] = [
'#type' => 'tel',
'#title' => $this
->t('Phone number'),
];
if (count($this->phoneNumbers)) {
$form['number']['#default_value'] = reset($this->phoneNumbers);
}
$form['submit'] = [
'#type' => 'submit',
'#value' => t('Send'),
'#weight' => 20,
];
// Add library for CSS styling.
$form['#attached']['library'] = 'sms_sendtophone/default';
return $form;
}