I have a site in drupal 9. I have one taxonomy with the name and and another field. I have a Go back button which takes me to a separate destination. The problem is that I cant click go back without giving some values in the name field as it is by default a required field in drupal. I want to click go back without giving anything in that name field. How can i achieve this?

2 Answers 2


You didn't post any code, but it sounds like your back button is somehow submitting the form (because it is validating the form, and failing required validation).

So the solution is to make sure the back button is not part of the form.

On my own site, to add a back button to some webforms, I add this HTML in a block that is shown on the webform page:

<button onClick="window.history.back()" class="button">Back</button>

You can easily do something similar with standard HTML + JS.


Another option if you cannot move the back button out of the form (and if it uses the Form API), would be to use the #limit_validation_errors property to avoid any form validation.

The example below can be used if you are building the form by yourself. If using a hook_form_alter(), just add the #limit_validation_errors line.

$form['back'] = [
  '#type' => 'submit',
  '#value' => $this->t('Back'),
  '#submit' => ['::yourSubmitCallback'],
  '#limit_validation_errors' => [], // This will ensure any validation is skipped

Your Answer

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

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