public function LearningPathCreateUserForm::buildForm in Opigno Learning path 8
Same name and namespace in other branches
- 3.x src/Form/LearningPathCreateUserForm.php \Drupal\opigno_learning_path\Form\LearningPathCreateUserForm::buildForm()
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/ LearningPathCreateUserForm.php, line 27
Class
- LearningPathCreateUserForm
- Members create form.
Namespace
Drupal\opigno_learning_path\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#prefix'] = '<div id="learning_path_create_user_form_messages" class="alert-danger"></div><div id="learning_path_create_user_form">';
$form['#suffix'] = '</div>';
$form['name'] = [
'#type' => 'textfield',
'#title' => $this
->t('User Name'),
'#placeholder' => $this
->t('Enter the learner name'),
];
$form['email'] = [
'#type' => 'textfield',
'#title' => $this
->t('Email Address'),
'#placeholder' => $this
->t('Enter the learner email'),
];
$form['create'] = [
'#type' => 'submit',
'#value' => $this
->t('Create new user'),
'#attributes' => [
'class' => [
'use-ajax',
'btn_create',
],
],
'#ajax' => [
'callback' => [
$this,
'submitFormAjax',
],
'event' => 'click',
],
];
$form['#attached']['library'][] = 'core/drupal.dialog.ajax';
$form['#attached']['library'][] = 'opigno_learning_path/create_member';
return $form;
}