Problem/Motivation
In #2647470: Write tests we removed #limit_validation_errors in order to support both mysql and pgsql. Let's try to add that back. See comment #16.
In that issue the following code was removed from the save button on the Credential form
#limit_validation_errors' => [
['driver'],
[$default_driver],
],And the related comment states that "Using #limit_validation_errors in the submit does not work so it is not possible to require the database and username for mysql and pgsql. This is because this is a multi-step form."
xjm queried if it wouldn't be better to change the required fields to not required rather than overriding them.
That makes the task at hand to decide if #limit_validation_errors should be restored to the form and if that also means a change to the required setting on the fields.
See below for resolution
Steps to reproduce
Steps to reproduce the bug:
- Install standard
- Install migrate_drupal_ui
- Go to /upgrade
- Click continue to get to upgrade/credentials
- If you have javascript enable the database name and user fields will be marked as required. But this is occurring only at the JS level and is not enforced via the form API - we've disabled it in \Drupal\migrate_drupal_ui\Form\CredentialForm::buildForm() but the #states from \Drupal\Core\Database\Install\Tasks::getFormOptions() is masking this when JS is enabled.
- Disable JS - you'll now see the require marker disappear
- If you submit the form you'll get a connection error saying
Resolve all issues below to continue the upgrade. Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO). Is the database server running? Does the database exist, and have you entered the correct database name? Have you entered the correct username and password? Have you entered the correct database hostname?
Proposed resolution
In #28 alexpott tested the form with and without JS enabled and thought the form works well enough as is and further suggested that this is a won't fix. quietone (#37) and mikelutz (#43) also agree that this is a won't fix.
However, the @todo's need to be removed from the file.
Remaining tasks
The decision is to mark this as won't fix. See #28, #29 and #31.
Make a patch to remove the @todo and leave a useful comment.Issue summary update, including this list!Reroll (Novice task)- Review
- Commit
User interface changes
None
API changes
N/A
Data model changes
N/A

| Comment | File | Size | Author |
|---|---|---|---|
| #45 | diff_reroll_2678510_37-45.txt | 1.31 KB | ankithashetty |
| #45 | 2678510-45.patch | 1.93 KB | ankithashetty |
| #38 | Screenshot 2020-07-28 at 11.40.14 AM.png | 48.65 KB | samiullah |
| #38 | Screenshot 2020-07-28 at 11.40.09 AM.png | 12.34 KB | samiullah |
| #37 | 2678510-37.patch | 1.91 KB | quietone |
Comments
Comment #2
xjmComment #6
mikeryanComment #7
yoroy commentedWe tried to understand what's being asked for here on our UX call but couldn't figure it out. Issue summary could do with a bit more detail :-)
Comment #8
quietone commentedComment #9
yoroy commentedReferencing a comment in another issue that also only explains things in code doesn't count :)
What is the actual proposed user interface change here?
Comment #10
mikeryanComment #11
Bojhan commentedNothing to review at this moment.
Comment #13
quietone commentedAssigning to myself.
Comment #14
quietone commentedComment #15
quietone commentedDid some testing of the form by adding the #limit_validation_error back and changing #required on the database and username fields. I discovered that the credential form is setup by a call to getFormOptions() which set those fields to required. MigrateUpgradeForm has code to set required to false on those fields, and it does (debugged that), but the form still displays those fields as required. Despite clearing the cache.
In the API documentation for #limit_validation_errors it uses an example of a "Previous" button on a form where you might want to submit despite not having valid data in the fields. Now, that makes sense but this form doesn't have a "Previous" or a "Cancel" . Maybe it should?
Comment #16
quietone commentedAdded a screenshot, IS upated.
Setting to NR to get some feed back on what to do here. Restore #limit_validation_errors or not?
Comment #17
heddnI'm not so sure this is really that major, with all the other priorities in migrate space. Lowering priority. There's a couple ways to mark something as required in the FAPI. And there's even a way to do in using the Javascript States API. I think the general idea is we want to conditionally make some of these fields require. Using the States API would be the preferred method, but setting things required in that manner has been traditionally complicate. But let's try it first.
Comment #18
heddnAnd now actually lowering priority.
Comment #19
heddnNeeds steps to reproduce the problem. Let's get those documented in here and update the IS.
Comment #25
pameeela commented@alexpott / @quietone is this issue still relevant? If so can you provide some steps to test that we can use to work on a patch?
Comment #26
quietone commentedTalked to pameeela on Slack, just adding my comments from there.
I am not familiar with #limit_validation_errors'. But I do know that if one makes the database and username fields required on the Credential Form then you can't successfully submit the form. Even when those fields are filled in you get errors,
Comment #27
alexpottThis is definitely still an issue. When you add the db credentials when configuring a migration fields that should be marked required are not marked as such.
Comment #28
alexpottI've added complete steps to reproduce to the issue summary.
So what's interesting is the form behaves great with JS enabled and it is okay without JS it's just that fields that should be marked as required are not but the error that's display is not bad at all... so perhaps this is a won't fix. Here's a screenshot that shows the bug (username field not required) and the error message when you submit.
Comment #29
quietone commentedIn this case I agree. However, is this exposing a problem in the #limit_validation_errors or #required in multi steps forms that should be addressed or is this another example of the uniqueness of migrate?
Comment #30
pameeela commentedComment #31
larowlanIt's just that we're using #states here - if we were using #ajax we could rebuild the form and set the #required as appropriate based on the user's selections
I'm inclined to won't fix too
Comment #32
quietone commentedRespectfully disagree, '#states' was introduced into the form in 8.5.x fcb7dd9 whereas the @todo about limitation errors was added when the form was still part of the contrib module Migrate Upgrade, #2647470: Write tests.
Comment #33
larowlanOk, no worries
Does this work as an alternative?
Adds html5 required attribute
Comment #34
larowlanProbably helps if I do it properly
Comment #35
quietone commentedI have manually tested the patch in #33 and #34 and they do not change the behavior of the form. And the second one causes a warning
Comment #37
quietone commentedI really appreciate that larowlan took the time to make a patch for this. It was fun to test as learn a bit more about forms.
In summary, this is a won't fix, well sort of. What is left to do is to remove any @todo pointing to this issue. And I've made the patch.
Removing unneeded tags.
Comment #38
samiullah commented@quietone, I have applied ur patch on clean install of drupal 9.1x
1. Normally if user clicks on review upgrade then js pop is shown for required fields which is fine
2. If by mistake i add space to database name, and click on review upgrade i see the error message as quoted in issue description, can we add a trim to this field if only space is added.
Comment #39
quietone commented@samiullah, I am not able to reproduce that result. I can't get an access denied for a database field that is empty or only contains spaces. Please provide complete steps to reproduce.
Comment #40
samiullah commented@quietone
Steps to replicate
1. Install standard drupal 9.1x
2. Enable migrate_drupal_ui
3. Go to /upgrade
4. Click continue to get to upgrade/credentials
5. Apply the latest patch
6. Clear the cache
7. Disable browser JS
8. In Database Name field enter space only
9. Click on review upgrade
10. Observe the error message
Comment #41
quietone commented@samiullah, thank you for the steps to reproduce. I do get the same results as in #38 with javascript disabled. The only difference is that I did not apply the latest patch because it only changes some comments, it does not change any code. Without javascript the form is working well enough and that agrees with the comment in #28 that "without JS it's just that fields that should be marked as required are not but the error that's display is not bad at all".
Your second point about trimming the value entered in the database field needs is outside the scope of this one. Please make a new issue for that. Thanks.
Comment #42
samiullah commented@quietone I have created a new issue for trimming spaces only https://www.drupal.org/project/drupal/issues/3162323
Comment #43
mikelutzAnother straightforward review. I agree to not fix and remove the todos. I've adjusted the issue title,
Comment #44
benjifisherIMO, the status should already be NW if the issue summary needs an update.
The patch in #37 needs a reroll, which certainly means the status should be NW. I am adding the appropriate issue tags.
Comment #45
ankithashettyRe-rolled the patch in #37. Retaining status as "Needs Work" because the issue summary needs an update as mentioned in #44...
Thank you!
Comment #46
quietone commentedUpdated the IS
Comment #47
pameeela commentedGreen patch and updated IS, this is ready to go.
Comment #48
alexpottCommitted and pushed a5ef3af6af to 9.1.x and efae4a62ac to 9.0.x and c8e85e37d9 to 8.9.x. Thanks!
Backported to 8.9.x since this is about code comments only.