protected function GroupContentForm::actions in Group 8
Same name and namespace in other branches
- 2.0.x src/Entity/Form/GroupContentForm.php \Drupal\group\Entity\Form\GroupContentForm::actions()
Returns an array of supported actions for the current entity form.
This function generates a list of Form API elements which represent actions supported by the current entity form.
@todo Consider introducing a 'preview' action here, since it is used by many entity types.
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 An array of supported Form API action elements keyed by name.
Overrides EntityForm::actions
1 call to GroupContentForm::actions()
- GroupJoinForm::actions in src/
Form/ GroupJoinForm.php - Returns an array of supported actions for the current entity form.
1 method overrides GroupContentForm::actions()
- GroupJoinForm::actions in src/
Form/ GroupJoinForm.php - Returns an array of supported actions for the current entity form.
File
- src/
Entity/ Form/ GroupContentForm.php, line 63
Class
- GroupContentForm
- Form controller for the group content edit forms.
Namespace
Drupal\group\Entity\FormCode
protected function actions(array $form, FormStateInterface $form_state) {
$actions = parent::actions($form, $form_state);
// If we are on step 2 of a wizard, we need to alter the actions.
if ($form_state
->get('group_wizard')) {
$wizard_id = $form_state
->get('group_wizard_id');
$store = $this->privateTempStoreFactory
->get($wizard_id);
$store_id = $form_state
->get('store_id');
if ($store
->get("{$store_id}:step") === 2) {
// Add a back button to return to step 1 with.
$actions['back'] = [
'#type' => 'submit',
'#value' => $this
->t('Back'),
'#submit' => [
'::back',
],
'#limit_validation_errors' => [],
];
// Make the label of the save button more intuitive.
if ($wizard_id == 'group_creator') {
$actions['submit']['#value'] = $this
->t('Save group and membership');
}
elseif ($wizard_id == 'group_entity') {
$entity_type_id = $store
->get("{$store_id}:entity")
->getEntityTypeId();
$entity_type = $this->entityTypeManager
->getDefinition($entity_type_id);
$replace = [
'@entity_type' => $entity_type
->getSingularLabel(),
'@group' => $this
->getEntity()
->getGroup()
->label(),
];
$actions['submit']['#value'] = $this
->t('Add new @entity_type to @group', $replace);
}
// Make sure we complete the wizard before saving the group content.
$index = array_search('::save', $actions['submit']['#submit']);
array_splice($actions['submit']['#submit'], $index, 0, '::complete');
}
}
return $actions;
}