Commit ff41283c authored by alexpott's avatar alexpott

Issue #2367743 by rpayanm, Miroling, YesCT, ianthomas_uk, shadik,...

Issue #2367743 by rpayanm, Miroling, YesCT, ianthomas_uk, shadik, gaurav.pahuja: Remove usages of drupal_form_submit() and update documentation
parent 39671958
......@@ -212,9 +212,9 @@ function _batch_process() {
$set_changed = TRUE;
// If this batch was marked for progressive execution (e.g. forms submitted by
// drupal_form_submit()), initialize a timer to determine whether we need to
// proceed with the same batch phase when a processing time of 1 second has
// been exceeded.
// \Drupal::formBuilder()->submitForm(), initialize a timer to determine
// whether we need to proceed with the same batch phase when a processing time
// of 1 second has been exceeded.
if ($batch['progressive']) {
Timer::start('batch_processing');
}
......
......@@ -168,7 +168,8 @@ function install_drupal($class_loader, $settings = array()) {
* be used to programmatically submit forms during the installation; the keys
* of each element indicate the name of the installation task that the form
* submission is for, and the values are used as the $form_state->getValues()
* array that is passed on to the form submission via drupal_form_submit()).
* array that is passed on to the form submission via
* \Drupal::formBuilder()->submitForm()).
*
* @see \Drupal\Core\Form\FormBuilderInterface::submitForm()
*/
......@@ -197,7 +198,7 @@ function install_state_defaults() {
// installation. The keys of each element indicate the name of the
// installation task that the form submission is for, and the values are
// used as the $form_state->getValues() array that is passed on to the form
// submission via drupal_form_submit().
// submission via \Drupal::formBuilder()->submitForm().
'forms' => array(),
// This becomes TRUE only at the end of the installation process, after
// all available tasks have been completed and Drupal is fully installed.
......
......@@ -150,7 +150,7 @@ public function rebuildForm($form_id, FormStateInterface &$form_state, $old_form
* @code
* $form_state->setValues($my_form_values);
* $form_state->addBuildInfo('args', [&$object]);
* drupal_form_submit('mymodule_form', $form_state);
* \Drupal::formBuilder()->submitForm('mymodule_form', $form_state);
* @endcode
* For example:
* @code
......@@ -162,7 +162,7 @@ public function rebuildForm($form_id, FormStateInterface &$form_state, $old_form
* $values['pass']['pass2'] = 'password';
* $values['op'] = t('Create new account');
* $form_state->setValues($values);
* drupal_form_submit('user_register_form', $form_state);
* \Drupal::formBuilder()->submitForm('user_register_form', $form_state);
* @endcode
*/
public function submitForm($form_arg, FormStateInterface &$form_state);
......
......@@ -95,12 +95,12 @@ public static function valueCallback(&$element, $input, FormStateInterface $form
}
elseif (is_array($input)) {
// Programmatic form submissions use NULL to indicate that a checkbox
// should be unchecked; see drupal_form_submit(). We therefore remove all
// NULL elements from the array before constructing the return value, to
// simulate the behavior of web browsers (which do not send unchecked
// checkboxes to the server at all). This will not affect non-programmatic
// form submissions, since all values in \Drupal::request()->request are
// strings.
// should be unchecked. We therefore remove all NULL elements from the
// array before constructing the return value, to simulate the behavior
// of web browsers (which do not send unchecked checkboxes to the server
// at all). This will not affect non-programmatic form submissions, since
// all values in \Drupal::request()->request are strings.
// @see \Drupal\Core\Form\FormBuilderInterface::submitForm()
foreach ($input as $key => $value) {
if (!isset($value)) {
unset($input[$key]);
......
......@@ -13,8 +13,9 @@
* Stores token data in a hidden form field.
*
* This is generally used to protect against cross-site forgeries. A token
* element is automatically added to each Drupal form by drupal_prepare_form(),
* so you don't generally have to add one yourself.
* element is automatically added to each Drupal form by an implementation of
* \Drupal\Core\Form\FormBuilderInterface::prepareForm() so you don't generally
* have to add one yourself.
*
* @FormElement("token")
*/
......
......@@ -94,7 +94,7 @@ protected function setUp() {
}
// Note that WebTestBase::installParameters() returns form input values
// suitable for a programmed drupal_form_submit().
// suitable for a programmed \Drupal::formBuilder()->submitForm().
// @see WebTestBase::translatePostValues()
$this->parameters = $this->installParameters();
......
......@@ -129,14 +129,14 @@ function testBatchFormProgrammatic() {
}
/**
* Tests that drupal_form_submit() can run within a batch operation.
* Test form submission during a batch operation.
*/
function testDrupalFormSubmitInBatch() {
// Displaying the page triggers a batch that programmatically submits a
// form.
$value = rand(0, 255);
$this->drupalGet('batch-test/nested-programmatic/' . $value);
$this->assertEqual(batch_test_stack(), array('mock form submitted with value = ' . $value), 'drupal_form_submit() ran successfully within a batch operation.');
$this->assertEqual(batch_test_stack(), array('mock form submitted with value = ' . $value), '\Drupal::formBuilder()->submitForm() ran successfully within a batch operation.');
}
/**
......
......@@ -8,7 +8,7 @@
use Drupal\Core\Form\FormState;
/**
* Batch operation: Submits form_test_mock_form() using drupal_form_submit().
* Batch operation: Submits form_test_mock_form().
*/
function _batch_test_nested_drupal_form_submit_callback($value) {
$form_state = (new FormState())
......
......@@ -76,7 +76,7 @@ public function testNoForm() {
* Submits the 'Chained' form programmatically.
*
* Programmatic form: the page submits the 'Chained' form through
* drupal_form_submit().
* \Drupal::formBuilder()->submitForm().
*
* @param int $value
* Some value passed to a the chained form.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment