1

I have built a multi-step webform which has some field on first page (checkboxes, selectboxes etc.). I tried to access $form_state on second page in MYTHEME_form_alter where is checked if $form['progress']['#current_page'] == 'second_page'.

When am I on second page I add custom element via $form variable

$form['custom'] = [
    'button_generate' => [
        '#type' => 'submit',
        '#value' => t('Download as PDF'),
        '#limit_validation_errors' => [],
        '#submit' => ['createPdfTemplate'],
    ]
];

this is how createPdfTemplate looks

function createPdfTemplate(array $form, FormStateInterface &$form_state)
{
    dd($form_state->getValues());
}

I'm trying to get data from $form_state from 'first_page' and put them into twig template, but somehow in createPdfTemplate I can only access info about my button (i mean: $form['custom']['button_generate']) that called the action.

Anyone who could give me a hint what am i doing wrong, please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.