-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocial_conversational_form.module
51 lines (44 loc) · 1.45 KB
/
social_conversational_form.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* @file
* Module file for Social Conversational Form.
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_FORM_ID_alter().
*
* {@inheritdoc}
*/
function social_conversational_form_form_user_register_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
// Set the context for the conversational form.
$form['#prefix'] = '<div cf-context>';
$form['#suffix'] = '</div>';
if ($_GET['conv'] == 'off') {
}
else {
// Attach the library.
$form['#attached']['library'][] = 'social_conversational_form/social_conversational_form';
}
$form['account']['mail']['#attributes']['cf-questions'] = 'Hi there {firstname}!&&What is your email address?';
$form['account']['name']['#attributes']['cf-questions'] = 'What do you want your username to be?';
$form['firstname'] = array(
'#type' => 'textfield',
'#title' => t('First name'),
'#required' => FALSE,
'#weight' => -100,
'#attributes' => [
'id' => 'firstname',
'cf-questions' => "Hi there!&&Nice to see you want to register at our community.&&What is your first name?"],
'cf-error' => 'Make sure your first name does not contain numbers',
);
$form['profession'] = [
'#type' => 'select',
'#title' => t("What is your profession?"),
'#options' => [
'1' => t('Icecream truck driver'),
'2' => t('Badminton supporter'),
'3' => t('Stay at home mom'),
'4' => t('Stay at home dad'),
],
];
}