function domain_source_form_alter in Domain Access 8
Same name and namespace in other branches
- 5 domain_source/domain_source.module \domain_source_form_alter()
- 6.2 domain_source/domain_source.module \domain_source_form_alter()
- 7.3 domain_source/domain_source.module \domain_source_form_alter()
- 7.2 domain_source/domain_source.module \domain_source_form_alter()
Implements hook_form_alter().
Find forms that contain the domain source field and allow those to handle redirects properly.
File
- domain_source/
domain_source.module, line 134 - Domain-based path rewrites for content.
Code
function domain_source_form_alter(&$form, &$form_state, $form_id) {
$object = $form_state
->getFormObject();
// Set up our TrustedRedirect handler for form saves.
if (isset($form[DomainSourceElementManagerInterface::DOMAIN_SOURCE_FIELD]) && !empty($object) && is_callable([
$object,
'getEntity',
]) && ($entity = $object
->getEntity())) {
// Validate the form.
$form['#validate'][] = 'domain_source_form_validate';
foreach ($form['actions'] as $key => $element) {
// Redirect submit handlers, but not the preview button.
if ($key != 'preview' && isset($element['#type']) && $element['#type'] == 'submit') {
$form['actions'][$key]['#submit'][] = 'domain_source_form_submit';
}
}
}
}