Skip to content

Commit

Permalink
Add media save redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
rosiel committed Sep 22, 2023
1 parent e3399d3 commit fdfdd87
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions islandora.module
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ function islandora_form_alter(&$form, FormStateInterface $form_state, $form_id)
if ($node) {
$form['name']['widget'][0]['value']['#default_value'] = $node->getTitle();
}
$form['actions']['submit']['#submit'][] = 'islandora_media_custom_form_submit';
}
}

Expand Down Expand Up @@ -387,6 +388,20 @@ function islandora_form_alter(&$form, FormStateInterface $form_state, $form_id)
return $form;
}

/**
* Redirect submit handler for media save.
*/
function islandora_media_custom_form_submit(&$form, FormStateInterface $form_state) {
$params = \Drupal::request()->query->all();

if (!empty($params)) {
$target_id = $params['edit']['field_media_of']['widget'][0]['target_id'];
$url = Url::fromRoute('entity.node.canonical', ['node' => $target_id]);
$form_state->setRedirectUrl($url);
}

}

/**
* Implements a submit handler for the delete form.
*/
Expand Down

0 comments on commit fdfdd87

Please sign in to comment.