Commit 2317a396 authored by catch's avatar catch
Browse files

Issue #2773333 by Berdir, Juterpillar, Wim Leers, Fabianx, renukakulkarni:...

Issue #2773333 by Berdir, Juterpillar, Wim Leers, Fabianx, renukakulkarni: Form validation errors, status messages on form submission are shown after page refresh when form is rendered in block
parent b39b29ad
......@@ -1591,10 +1591,13 @@ services:
- { name: mime_type_guesser }
lazy: true
# Currently needs to be public as it is called by
# \Drupal\Core\Render\Element\StatusMessages.
# @todo Consider making this service private again after
# lands.
class: Drupal\Core\Render\PlaceholderGenerator
arguments: ['%renderer.config%']
public: false
class: Drupal\Core\Render\PlaceholderingRenderCache
arguments: ['@request_stack', '@cache_factory', '@cache_contexts_manager', '@render_placeholder_generator']
......@@ -45,12 +45,15 @@ public function getInfo() {
* The updated renderable array containing the placeholder.
public static function generatePlaceholder(array $element) {
$element['messages_placeholder'] = [
$element = [
'#lazy_builder' => [get_class() . '::renderMessages', [$element['#display']]],
'#create_placeholder' => TRUE,
return $element;
// Directly create a placeholder as we need this to be placeholdered
// regardless if this is a POST or GET request.
// @todo remove this when lands.
return \Drupal::service('render_placeholder_generator')->createPlaceholder($element);
......@@ -87,6 +87,17 @@ function testUserLoginBlock() {
$this->drupalPostForm('', $edit, t('Log in'), array('external' => FALSE));
// Check that we remain on the site after login.
$this->assertUrl($user->url('canonical', ['absolute' => TRUE]), [], 'Redirected to user profile page after login from the frontpage');
// Verify that form validation errors are displayed immediately for forms
// in blocks and not on subsequent page requests.
$edit = array();
$edit['name'] = 'foo';
$edit['pass'] = 'invalid password';
$this->drupalPostForm('filter/tips', $edit, t('Log in'));
$this->assertText(t('Unrecognized username or password. Forgot your password?'));
$this->assertNoText(t('Unrecognized username or password. Forgot your password?'));
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