function workbench_email_form_moderation_state_transition_edit_form_alter in Workbench Email 8
Same name and namespace in other branches
- 2.x workbench_email.module \workbench_email_form_moderation_state_transition_edit_form_alter()
Implements hook_form_FORM_ID_alter() for moderation_state_transition_edit_form.
File
- ./
workbench_email.module, line 33 - Provides main module functions.
Code
function workbench_email_form_moderation_state_transition_edit_form_alter(&$form, FormStateInterface $form_state) {
// Alter the transition form to add the fields to choose the templates.
/** @var \Drupal\workbench_moderation\Entity\ModerationStateTransition $transition */
$form_object = $form_state
->getFormObject();
if (!in_array($form_object
->getOperation(), [
'edit',
'add',
], TRUE)) {
// Only alter the edit and add forms.
return;
}
workbench_email_form_workflow_transition_add_form_alter($form, $form_state);
// And add an entity builder.
$form['#entity_builders'][] = 'workbench_email_transition_edit_builder';
// Fix the default value.
$form['workbench_email_templates']['#default_value'] = $form_state
->getFormObject()
->getEntity()
->getThirdPartySetting('workbench_email', 'workbench_email_templates', []);
}