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 :
- Define a block Plugin like GoogleCurrencyConverterBlock which embeds the form in build
- Add a Custom form so that we embed in in the block build method. Define the custom validation method in the form.
- 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)
- 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 :
- Go to https://simplytest.me/project/google_currency_converter/8.x-1.x
- Add the patch in Apply patches section on the screen https://www.drupal.org/files/issues/2772235-5.patch
- And follow the steps to reproduce as mentioned above.
Comment | File | Size | Author |
---|---|---|---|
#12 | 2772241-block-12.patch | 1017 bytes | tim.plunkett |
#10 | 2772241-10.patch | 817 bytes | naveenvalecha |
Comments
Comment #2
naveenvalechaIt's a bug so bumping it back to 8.x-1.x-dev
Comment #3
tim.plunkettPlease define "not working", and provide steps to reproduce.
Comment #4
naveenvalechaAdded steps to reproduce and usecase as well.
Comment #5
naveenvalechaComment #6
tim.plunkettYou have two options, I believe.
1) Make it
$form['actions']['submit']['#validate'][] = '::validateFinal';
2) Instead of a custom
validateFinal()
, use the built-invalidateForm()
Comment #7
naveenvalecha#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)
Comment #8
tim.plunkettYou are correct, this is a duplicate of that issue.
Comment #9
naveenvalechaAs 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.
Comment #10
naveenvalechaAttached is the patch to prove it.
Comment #11
naveenvalechaComment #12
tim.plunkettUnfortunately, that patch doesn't prove anything.
This passes.
Comment #16
tim.plunkett5.5 and 5.6 are failing with DIFFERENT FAILURES!?!
5.5, which I'm guessing you're hitting (I'm on 5.6)
5.6, which looks unrelated
Comment #17
naveenvalechaRerunning the tests to make sure that random failures are different from exact problem.
Comment #19
tim.plunkettThe random fails in 5.6 are from #2762549: Drupal\field\Tests\Update\FieldUpdateTest, Drupal\views\Tests\Update\EntityViewsDataUpdateTest and Drupal\comment\Tests\CommentFieldsTest fail on 8.1.x.
So what is different about 5.5?!
Comment #20
naveenvalechaThe 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
Comment #22
naveenvalechaThe issue in contrib project was due to #2773333: Form validation errors, status messages on form submission are shown after page refresh when form is rendered in block Closing this as duplicate