Linked Questions

17 votes
5 answers
27k views

How do you implement a custom submit handler in hook_form_alter()?

I've been updating one of my Drupal 7 modules to 8 and I'm having an issue with my form alter. I'm adding a validation function and a submit handler. The validation function is getting called just ...
Arbee's user avatar
  • 181
12 votes
2 answers
4k views

Force redirect in submit handler even though destination parameter set

I add a custom submit handler and now I want Redirect to custom route after form submitted. This is what I used use Drupal\Core\Form\FormStateInterface; use Symfony\Component\HttpFoundation\Request;...
Yuseferi's user avatar
  • 22.1k
3 votes
3 answers
7k views

Programmatically adding fields to node submission form

I need to add fields to a node creation/editing form programmatically. More specifically, I need to take already-generated form elements from another form and insert them into the node submission form....
beth's user avatar
  • 9,087
2 votes
1 answer
4k views

Page redirect in custom WebformHandlerBase

I have written a custom WebformHandlerBase and attached it to the Mulitpage webform. With this I'm able to get the values into the custom handler as soon as user clicks on Next Page> button class ...
Rahul D's user avatar
  • 101
0 votes
2 answers
3k views

Get value of programmatically (form_alter) added fields at form submit

I'm altering a node creation form using the form_alter hook in a custom module. In this particular case, I'm adding an email field which is not part of the content type structure. At the node creation,...
Gabriele's user avatar
  • 135
1 vote
1 answer
2k views

Installing/Enabling Custom Webform Hander

I am very new to Drupal development though I am an experienced developer. I created a custom Webform Handler following these tutorials and postings: These for what files to create and where: Create a ...
iJared's user avatar
  • 115
1 vote
1 answer
2k views

Prevent redirection after comment submission

When a user add a comment on a node, I would like to prevent the page reload. I added a form_alter in my theme function theme_form_alter(&$form, &$form_state, $form_id) { switch($form_id)...
Tibo's user avatar
  • 241
0 votes
1 answer
2k views

Which hook can I use before or after submitting a webform form?

I created a webform form with drupal 8. I would like to populate a database table with information from my form before or after submitting. I guess there must be a hook like hook_webform_pressave () ...
Pascal Pivaty's user avatar
2 votes
1 answer
1k views

node_delete_confirm_submit() and hook_node_delete()

Still getting my head around Drupal 8 after using Drupal 7 for so long. I want to override (alter) the node delete action. Now in Drupal 7 I would have used node_delete_confirm_submit() and ...
user avatar
0 votes
1 answer
728 views

Get the draft data in the webform hook_form_FORM_ID_alter()

I'm building a multi page webform in Drupal 8 as shown below (1) Consent to ask questions >>> (2) Chekcing eligiblity >>> (3) Consent to Participate >>> (4) Base line info >>> (5) Complete ...
Rahul D's user avatar
  • 101
0 votes
1 answer
315 views

Extract email addresses from composite field type using Computed Twig

I am using a custom composite field type to gather multiple pieces of data from a user. This custom composite field type contains a field which gathers the email addresses entered. What I am trying to ...
Jon's user avatar
  • 3
0 votes
1 answer
75 views

My submit function for the node form doesn't execute

I need to add my submit function to the node insert/edit form. Here's my code. function yrv_event_trainer_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) { if (...
Yakimkin Roman's user avatar
1 vote
1 answer
85 views

How can I use EntityForm ::save() in a custom module? [closed]

How can i call public function ContactFormEditForm::save. My goal is refer to return value, do something like email, custom logged message, etc. Refer to api."Return value int Either SAVED_NEW or ...
user76445's user avatar
1 vote
1 answer
46 views

Renaming a webform handler - old class stuck in DB despite clearing cache

I'm creating a custom webform handler plugin based on the advice here, adding the class, in the correct directory, to an existing module. I got the class name / some of the docblock info wrong ...
William Turrell's user avatar
0 votes
1 answer
51 views

hook_form_form_id_alter doesn't save data by default

I use hook_form_form_id_alter() to edit the user_form. I'm creating some checkboxes and textfields. Thats working fine. I also can output the values, when clicking the submit button. But it doesn't ...
Mayari's user avatar
  • 169