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/jsonandapplication/vnd.drupal-ajaxresponses. (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