public function LdapUserMappingToLdapForm::buildForm in Lightweight Directory Access Protocol (LDAP) 8.4
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 ConfigFormBase::buildForm
File
- ldap_user/
src/ Form/ LdapUserMappingToLdapForm.php, line 58
Class
- LdapUserMappingToLdapForm
- Provides the form to configure user configuration and field mapping.
Namespace
Drupal\ldap_user\FormCode
public function buildForm(array $form, FormStateInterface $form_state) : array {
$form['header'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Mappings synced from Drupal to LDAP'),
'#description' => $this
->t('See also the <a href="@wiki_link">Drupal.org wiki page</a> for further information on using LDAP tokens.', [
'@wiki_link' => 'https://drupal.org/node/1245736',
]),
];
$form['mappings'] = [
'#type' => 'table',
'#header' => [
$this
->t('Label'),
$this
->t('Machine name'),
$this
->t('Weight'),
$this
->t('Operations'),
],
'#attributes' => [
'class' => [
'mappings-table',
],
],
'#prefix' => '<div id="ldap-user-mappings-wrapper">',
'#suffix' => '</div>',
];
$form['mappings']['#header'] = [
[
'data' => $this
->t('Source Drupal user attribute'),
'rowspan' => 1,
'colspan' => 3,
],
[
'data' => $this
->t('Target LDAP token'),
],
[
'data' => $this
->t('Synchronization event'),
'colspan' => 2,
'rowspan' => 1,
],
[
'data' => $this
->t('Delete'),
],
[],
];
$form['mappings']['second-header'] = [
'#attributes' => [
'class' => 'header',
],
[
'#title' => $this
->t('Note: Select <em>user tokens</em> to use token field.'),
'#type' => 'item',
],
[
'#title' => $this
->t('Source Drupal user tokens such as: <ul><li>[property.name]</li><li>[field.field_fname]</li><li>[field.field_lname]</li></ul> Constants such as <em>from_drupal</em> or <em>18</em> should not be enclosed in [].'),
'#type' => 'item',
],
[
'#title' => $this
->t('Convert From binary'),
'#type' => 'item',
],
[
'#title' => $this
->t('Use singular token format such as: <ul><li>[sn]</li><li>[givenName]</li></ul>'),
'#type' => 'item',
],
[
'#title' => $this
->t('On LDAP Entry Creation'),
'#type' => 'item',
'#class' => 'header-provisioning',
'#rowspan' => 2,
],
[
'#title' => $this
->t('On Sync to LDAP Entry'),
'#type' => 'item',
'#class' => 'header-provisioning',
],
[],
[],
];
$mappings_to_add = $this
->getServerMappingFields($form_state);
if ($mappings_to_add) {
$form['mappings'] += $mappings_to_add;
}
$form['mappings'][]['mappings_add_another'] = [
'#type' => 'submit',
'#value' => $this
->t('Add Another'),
'#submit' => [
'::mappingsAddAnother',
],
'#limit_validation_errors' => [],
'#ajax' => [
'callback' => '::mappingsAjaxCallback',
'wrapper' => 'ldap-user-mappings-wrapper',
],
'#weight' => 103,
'#wrapper_attributes' => [
'colspan' => 5,
],
];
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => 'Save',
];
return $form;
}