Follow-up to #2772235: Add test coverage for GoogleCurrencyConverterForm validateFinal Method

Embedded Form validation errors not showing on page.They are showing if you'll refresh the page.

Usecase :
Google Currency Converter module embeded the custom form into Block plugin ::build method, the validation provided by form is not working as defined.

Steps to Reproduce :

  1. Define a block Plugin like GoogleCurrencyConverterBlock which embeds the form in build
  2. Add a Custom form so that we embed in in the block build method. Define the custom validation method in the form.
  3. Now place the block on home page.(Note: The block configuration validation is not working due to #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) so don't post about it)
  4. Go to homepage and select from and to currency as same, Now the validation will work and it will focus on the wrong data element but it will not show the error, what's the exact error it is.

Testing of exact problem in google currency converter project on simplytest.me :

  1. Go to https://simplytest.me/project/google_currency_converter/8.x-1.x
  2. Add the patch in Apply patches section on the screen https://www.drupal.org/files/issues/2772235-5.patch
  3. And follow the steps to reproduce as mentioned above.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

naveenvalecha created an issue. See original summary.

naveenvalecha’s picture

Version: 8.2.x-dev » 8.1.x-dev

It's a bug so bumping it back to 8.x-1.x-dev

tim.plunkett’s picture

Status: Active » Postponed (maintainer needs more info)

Please define "not working", and provide steps to reproduce.

naveenvalecha’s picture

Title: Embedec Form validation is not working in the block » Embeded Form validation is not working in the block
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Added steps to reproduce and usecase as well.

naveenvalecha’s picture

Issue summary: View changes
tim.plunkett’s picture

Category: Bug report » Support request

You have two options, I believe.

1) Make it $form['actions']['submit']['#validate'][] = '::validateFinal';
2) Instead of a custom validateFinal(), use the built-in validateForm()

naveenvalecha’s picture

Title: Embeded Form validation is not working in the block » Embedded Form validation errors not showing in block
Category: Support request » Bug report
Issue summary: View changes

#6,

Thanks tried both options. the validation is working now, but the form set error messages are not displaying.

bumping this back to bug, b/c I have tried with both options.

Regarding the block configuration validation form error, I have found that its due to #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms)

tim.plunkett’s picture

Status: Active » Closed (duplicate)

You are correct, this is a duplicate of that issue.

naveenvalecha’s picture

Status: Closed (duplicate) » Active

As the #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) gets fixed. I have retested the problem and it still exists with 8.2.x as well.

I have reused the issue for the problem. Please re-read the problem above and steps to reproduce.

naveenvalecha’s picture

Title: Embedded Form validation errors not showing in block » Embedded BlockFormInBlock validation errors not showing in block
Version: 8.1.x-dev » 8.2.x-dev
FileSize
817 bytes

Attached is the patch to prove it.

naveenvalecha’s picture

Status: Active » Needs review
tim.plunkett’s picture

Unfortunately, that patch doesn't prove anything.
This passes.

The last submitted patch, 10: 2772241-10.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 12: 2772241-block-12.patch, failed testing.

The last submitted patch, 12: 2772241-block-12.patch, failed testing.

tim.plunkett’s picture

5.5 and 5.6 are failing with DIFFERENT FAILURES!?!

5.5, which I'm guessing you're hitting (I'm on 5.6)

Block.Drupal\block\Tests\BlockFormInBlockTest::testCachePerPage

fail: [Other] Line 51 of core/modules/block/src/Tests/BlockFormInBlockTest.php:
"This is not a .com email address." found

5.6, which looks unrelated

Comment.Drupal\comment\Tests\CommentFieldsTest::testCommentInstallAfterContentModule

exception: [Warning] Line 177 of core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php:
uasort(): Array was modified by the user comparison functionuasort(Array, Array) (Line: 177)
naveenvalecha’s picture

Rerunning the tests to make sure that random failures are different from exact problem.

The last submitted patch, 12: 2772241-block-12.patch, failed testing.

tim.plunkett’s picture

naveenvalecha’s picture

The failures are random for me too in my patched module #2772235: Add test coverage for GoogleCurrencyConverterForm validateFinal Method I'll contrib module issue this weekend and will post more updates and findings so that we can reproduce it here as well.

Check #12, The tests are green for 5.5 as well

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

naveenvalecha’s picture

Status: Needs work » Closed (duplicate)