diff --git a/core/modules/views/includes/ajax.inc b/core/modules/views/includes/ajax.inc index 0bcb723..e8d22d1 100644 --- a/core/modules/views/includes/ajax.inc +++ b/core/modules/views/includes/ajax.inc @@ -13,7 +13,7 @@ * Wrapper around drupal_build_form to handle some AJAX stuff automatically. * This makes some assumptions about the client. */ -function views_ajax_form_wrapper($form_id, &$form_state) { +function views_ajax_form_wrapper($form_class, &$form_state) { // This won't override settings already in. $form_state += array( 'rerender' => FALSE, @@ -24,7 +24,7 @@ function views_ajax_form_wrapper($form_id, &$form_state) { ), ); - $form = drupal_build_form($form_id, $form_state); + $form = \Drupal::formBuilder()->buildForm($form_class, $form_state); $output = drupal_render($form); // These forms have the title built in, so set the title here: diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index c6cb25f..ecf8973 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -128,7 +128,8 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { // before rendering the second time. $drupal_add_js_original = _drupal_add_js(); $drupal_add_js = &drupal_static('_drupal_add_js'); - $response = views_ajax_form_wrapper($form_state['form_id'], $form_state); + $form_class = get_class($form_state['build_info']['callback_object']); + $response = views_ajax_form_wrapper($form_class, $form_state); // If the form has not been submitted, or was not set for rerendering, stop. if (!$form_state['submitted'] || !empty($form_state['rerender'])) { @@ -151,7 +152,7 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { return new RedirectResponse(url($form_path, array('absolute' => TRUE))); } $form_state['path'] = $form_path; - $response = views_ajax_form_wrapper($form_state['form_id'], $form_state); + $response = views_ajax_form_wrapper($form_class, $form_state); } elseif (!$form_state['ajax']) { // if nothing on the stack, non-js forms just go back to the main view editor. diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php index 0242a44..14622d2 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityFormBuilderTest.php @@ -49,11 +49,6 @@ protected function setUp() { * @covers ::getForm() */ public function testGetForm() { - $this->formBuilder->expects($this->once()) - ->method('buildForm') - ->with('the_form_id', $this->isType('array')) - ->will($this->returnValue('the form contents')); - $form_controller = $this->getMock('Drupal\Core\Entity\EntityFormInterface'); $form_controller->expects($this->any()) ->method('getFormId') @@ -63,6 +58,11 @@ public function testGetForm() { ->with('the_entity_type', 'default') ->will($this->returnValue($form_controller)); + $this->formBuilder->expects($this->once()) + ->method('buildForm') + ->with($form_controller, $this->isType('array')) + ->will($this->returnValue('the form contents')); + $entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); $entity->expects($this->once()) ->method('getEntityTypeId')