FormState::setResponse() only works when processing input

Created on 27 June 2016, about 9 years ago
Updated 31 July 2025, 6 days ago

Follow-up to #2313479: Add FormState::setResponse() β†’

Problem/Motivation

It is currently impossible to redirect or provide other response objects to change the form behavior during form build.

This is a bit of an edge case but because we no longer have drupal_goto() it is not possible to cause a redirect during a form build
Add a setResponse() method and use that instead of $form_state['response']

Commerce working around the need for this:
https://github.com/drupalcommerce/commerce/pull/419

Proposed resolution

Modify prepareForm to return responses always.

Remaining tasks

User interface changes

API changes

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

forms system

Created by

πŸ‡ΊπŸ‡ΈUnited States neclimdul Houston, TX

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡ΊπŸ‡ΈUnited States neclimdul Houston, TX

    Don't know what information is still needed. As noted by Tim, this is related to making the form builder behave consistently in πŸ› Do not allow form builder functions to return Response objects Needs work as well as I'll note #2367555: Deprecate EnforcedResponseException support β†’ .

    But both of those are moving slowly so there's not much that can happen here I don't think.

Production build 0.71.5 2024