1

I am trying to use hook_form_alter() to change the details of the CiviCRM Payment Processor for specific users (to change from live mode to test mode).

On Drupal 7 it's in $form['submitted'] when Page 2 is rendered. Many items are already there on Page 1, but this is not.

Are these somewhere else, or do I have to use a different mechanism, in Drupal 9?

1 Answer 1

0

You should use an extension. See here:

https://docs.civicrm.org/dev/en/latest/hooks/

But that's for CiviCRM hooks. Drupal hooks indeed still work in a .module file. Docs are here:

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21form.api.php/function/hook_form_alter/9

To see all of the various parts, you can use

$formValues = $form_state->getUserInput();
print_r($formValues);die;

once, in order to see all the values. You can then use

$form_state->setValue();

to set a value.

1
  • As above, I used a hook successfully but can't find the right thing to edit on D8/9 May 16, 2023 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.