Commit 2ec3fbcb authored by alexpott's avatar alexpott

Issue #2335673 by ashutoshsngh, oenie, rudins, er.pushpinderrana: Remove usage...

Issue #2335673 by ashutoshsngh, oenie, rudins, er.pushpinderrana: Remove usage of drupal_process_form()
parent 4fbd17d0
......@@ -335,7 +335,7 @@ function testEntityFormDisplayExtractFormValues() {
// Pretend the form has been built.
$form_state->setFormObject(\Drupal::entityManager()->getFormObject($entity_type, 'default'));
\Drupal::formBuilder()->prepareForm('field_test_entity_form', $form, $form_state);
drupal_process_form('field_test_entity_form', $form, $form_state);
\Drupal::formBuilder()->processForm('field_test_entity_form', $form, $form_state);
$form_state->setValue($this->fieldTestData->field_name, $values);
$form_state->setValue($this->fieldTestData->field_name_2, $values_2);
......
......@@ -62,7 +62,7 @@ public function upload(Request $request) {
$current_file_count = isset($current_element['#file_upload_delta']) ? $current_element['#file_upload_delta'] : 0;
// Process user input. $form and $form_state are modified in the process.
drupal_process_form($form['#form_id'], $form, $form_state);
$this->formBuilder->processForm($form['#form_id'], $form, $form_state);
// Retrieve the element to be rendered.
$form = NestedArray::getValue($form, $form_parents);
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Form\FormState;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\system\FileAjaxForm;
use Drupal\Core\Form\FormBuilderInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
......@@ -29,14 +30,25 @@ class FormAjaxController implements ContainerInjectionInterface {
*/
protected $logger;
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilderInterface
*/
protected $formBuilder;
/**
* Constructs a FormAjaxController object.
*
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
*
* @param \Drupal\Core\Form\FormBuilderInterface $form_builder
* The form builder.
*/
public function __construct(LoggerInterface $logger) {
public function __construct(LoggerInterface $logger, FormBuilderInterface $form_builder) {
$this->logger = $logger;
$this->formBuilder = $form_builder;
}
/**
......@@ -44,7 +56,8 @@ public function __construct(LoggerInterface $logger) {
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('logger.factory')->get('ajax')
$container->get('logger.factory')->get('ajax'),
$container->get('form_builder')
);
}
......@@ -71,7 +84,7 @@ public function content(Request $request) {
$form_state = $ajaxForm->getFormState();
$commands = $ajaxForm->getCommands();
drupal_process_form($form['#form_id'], $form, $form_state);
$this->formBuilder->processForm($form['#form_id'], $form, $form_state);
// We need to return the part of the form (or some other content) that needs
// to be re-rendered so the browser can update the page with changed content.
......@@ -116,7 +129,7 @@ protected function getForm(Request $request) {
$form_build_id = $request->request->get('form_build_id');
// Get the form from the cache.
$form = \Drupal::formBuilder()->getCache($form_build_id, $form_state);
$form = $this->formBuilder->getCache($form_build_id, $form_state);
if (!$form) {
// If $form cannot be loaded from the cache, the form_build_id must be
// invalid, which means that someone performed a POST request onto
......
......@@ -222,7 +222,7 @@ private function formSubmitHelper($form, $edit) {
\Drupal::formBuilder()->prepareForm($form_id, $form, $form_state);
drupal_process_form($form_id, $form, $form_state);
\Drupal::formBuilder()->processForm($form_id, $form, $form_state);
$errors = $form_state->getErrors();
......
......@@ -117,7 +117,7 @@ function testRequiredFields() {
// so we bypass it by setting the token to FALSE.
$form['#token'] = FALSE;
\Drupal::formBuilder()->prepareForm($form_id, $form, $form_state);
drupal_process_form($form_id, $form, $form_state);
\Drupal::formBuilder()->processForm($form_id, $form, $form_state);
$errors = $form_state->getErrors();
// Form elements of type 'radios' throw all sorts of PHP notices
// when you try to render them like this, so we ignore those for
......
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