protected function TawkToExtraSettingsForm::buildUserInfoInterface in Tawk.to - Live chat application (Drupal 8) 8
Same name and namespace in other branches
- 8.2 src/Form/TawkToExtraSettingsForm.php \Drupal\tawk_to\Form\TawkToExtraSettingsForm::buildUserInfoInterface()
Helper function for building the user info UI form.
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 array with the visibility UI added in.
1 call to TawkToExtraSettingsForm::buildUserInfoInterface()
- TawkToExtraSettingsForm::buildForm in src/
Form/ TawkToExtraSettingsForm.php - Form constructor.
File
- src/
Form/ TawkToExtraSettingsForm.php, line 189
Class
- TawkToExtraSettingsForm
- Provides form for block instance forms.
Namespace
Drupal\tawk_to\FormCode
protected function buildUserInfoInterface(array $form, FormStateInterface $form_state) {
$settings = $this
->config('tawk_to.settings');
$form['user'] = [
'#type' => 'fieldset',
'#title' => $this
->t('User info settings'),
];
$form['user']['show_user_name'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show user name in the widget'),
'#default_value' => $settings
->get('show_user_name'),
];
$form['user']['user_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('User name in the widget'),
'#description' => $this
->t('You can use tokens. E.g. [current-user:name].'),
'#default_value' => $settings
->get('user_name'),
'#states' => [
'visible' => [
':input[name*=show_user_name]' => [
'checked' => TRUE,
],
],
],
];
$form['user']['show_user_email'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Show user email in the widget'),
'#default_value' => $settings
->get('show_user_name'),
];
$form['user']['user_email'] = [
'#type' => 'textfield',
'#title' => $this
->t('User email in the widget'),
'#description' => $this
->t('You can use tokens. E.g. [current-user:mail].'),
'#default_value' => $settings
->get('user_email'),
'#states' => [
'visible' => [
':input[name*=show_user_email]' => [
'checked' => TRUE,
],
],
],
];
return $form;
}