public function AddMembersToGroup::buildConfigurationForm in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 8.5 modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 8.6 modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 8.7 modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 8.8 modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 10.3.x modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 10.1.x modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
- 10.2.x modules/social_features/social_group/src/Plugin/Action/AddMembersToGroup.php \Drupal\social_group\Plugin\Action\AddMembersToGroup::buildConfigurationForm()
Form constructor.
Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.
Parameters
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Return value
array The form structure.
Overrides PluginFormInterface::buildConfigurationForm
File
- modules/
social_features/ social_group/ src/ Plugin/ Action/ AddMembersToGroup.php, line 118
Class
- AddMembersToGroup
- Change group membership role.
Namespace
Drupal\social_group\Plugin\ActionCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form['#title'] = $this
->formatPlural($this->context['selected_count'], 'Add selected member to a group', 'Add @count selected members to a group');
$groups = Group::loadMultiple(social_group_get_all_groups());
$options = [];
// Grab all the groups, sorted by group type for the select list.
foreach ($groups as $group) {
/** @var \Drupal\group\Entity\GroupTypeInterface $group_type */
$group_type = $group
->getGroupType();
$options[$group_type
->label()][$group
->id()] = $group
->label();
}
$markup = $this
->formatPlural($this->context['selected_count'], 'Please select the group you want to add the member you have selected to', 'Please select the group you want to add the @count members you have selected to');
$form['description'] = [
'#markup' => $markup,
];
// Empty the options so we don't have a massive list of users.
unset($form['list']);
$form['groups'] = [
'#type' => 'select',
'#title' => $this
->t('Group'),
'#options' => $options,
];
$form['actions']['submit']['#value'] = $this
->t('Add to Group');
$form['actions']['submit']['#attributes']['class'] = [
'button button--primary js-form-submit form-submit btn js-form-submit btn-raised btn-primary waves-effect waves-btn waves-light',
];
$form['actions']['cancel']['#attributes']['class'] = [
'button button--danger btn btn-flat waves-effect waves-btn',
];
return $form;
}