Create custom form button that does not submit webform I have webform created via Webform UI, and it's multi-step webform.

In second step ('personal information') I add custom button using HOOK_form_alter with following code

'generate_pdf' =&gt; [
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Generate PDF'),
    '#limit_validation_errors' =&gt; [],
    '#submit' =&gt; ['generate_pdf_template'],
]


function generate_pdf_template takes values from $form, $form_state inserts them into twig templat, creates PDF and automatically downloads it.

My issue is, that this generate_pdf button submits the form and user is not able to send form via original submit button. Can I somehow prevent submission when generate_pdf is clicked so user can download PDF and still be able to send webform with original button and webform's handlers.
Something like this may work.

#name and #submit are required.

The name makes sure the button does not get confused with other submit buttons.

The #submit value calls a custom function you have to create.

#limit_validation_errors prevents form validation, which may or may not be useful.

  $form['generate_pdf'] = [
    '#type' =&gt; 'submit',
    '#value' =&gt; $this-&gt;t('Generate PDF'),
    '#name' =&gt; 'generatepdf',
    '#submit' =&gt; ['::generatepdf'],
    '#limit_validation_errors' =&gt; array(),
  ];