Skip to content

Commit

Permalink
making sure config is saved on form submit
Browse files Browse the repository at this point in the history
  • Loading branch information
zedmonds96 committed Jan 14, 2025
1 parent 557e95e commit ea56e33
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/metastore/modules/metastore_admin/metastore_admin.module
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,16 @@ function metastore_admin_form_alter(&$form, FormStateInterface $form_state, $for
* Submit handler to redirect after node save to dkan dataset content page.
*/
function metastore_admin_form_submit($form, FormStateInterface &$form_state) {
$config = \Drupal::config('metastore_admin.settings');
// Get the value of the checkbox from the form submission.
$redirect_to_datasets = $form_state->getValue('redirect_to_datasets');

// Save the value to the configuration.
\Drupal::configFactory()->getEditable('metastore_admin.settings')
->set('redirect_to_datasets', $redirect_to_datasets)
->save();

// Check if the redirect option is enabled before redirecting.
if ($config->get('redirect_to_datasets')) {
if ($redirect_to_datasets) {
$form_state->setRedirect('view.dkan_dataset_content.page_1');
}
}
Expand Down

0 comments on commit ea56e33

Please sign in to comment.