Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By Wim Leers on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
- In Drupal 7,
drupalPost()
anddrupalPostAJAX()
both have deeply embedded assumptions that they're being applied to forms. - In Drupal 8, we now have POST requests that receive
application/json
andapplication/vnd.drupal-ajax
responses. (e.g. rendering of AJAXy Views, contextual links, Edit module's metadata, etc.). Hence there is a need to simulate HTTP POST requests that aren't processed by a form controller. These were condemned to usecurlExec()
directly. - A new
drupalPost()
method, with a different signature than Drupal 7 one, has been introduced in Drupal 8 to deal with these requirements. - The former
drupalPost()
anddrupalPostAJAX()
methods have been renamed, while retaining the original arguments:drupalPost()
→drupalPostForm()
drupalPostAJAX()
→drupalPostAjaxForm()
Code example
- Before (Drupal 7):
-
... $this->drupalPost('admin/config/development/logging', $edit, t('Save configuration')); ...
- After (Drupal 8):
-
... $this->drupalPostForm('admin/config/development/logging', $edit, t('Save configuration')); ...
Impacts:
Module developers