Right now we just use textfields for every element, we need to more thoroughly implement schema to form elements. There could be an existing service for this? Otherwise we can write one.
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | 2624746-31.patch | 18.39 KB | sam152 |
| #31 | interdiff.txt | 5.66 KB | sam152 |
| #19 | interdiff.txt | 2.85 KB | sam152 |
| #19 | 2624746-19.patch | 18.25 KB | sam152 |
| #17 | interdiff.txt | 2.79 KB | sam152 |
Comments
Comment #2
sam152 commentedI can have a look at this.
Comment #3
benjy commentedMoving to migrate_api
Comment #4
sam152 commentedStarted on this, no tests and only a basic improvement pure textfields. Not sure how to approach sequences at this stage, likely some 'add another' AJAX? After writing this, part of me thinks 'MigrateProcessInterface' should just ship with a 'configForm' method as part of it's interface. Schema doesn't seem like a clean mapping to forms.
See system.site in the attached screenshot.
Comment #5
benjy commentedThe content_translation module in core already converts schema to forms, we could see what they do, but i'd imagine something like this for sequence:
With an ajax add more yes, but i'd be happy to commit this with just support for textfields and checkboxes, we can do the rest in a follow-up.
Adding a configForm method to process plugins is something we could do but i see a few disadvantages:
Comment #6
benjy commentedAnother thought, i'd accept sequence as a textfield and a description that tells you to comma separate values as a first pass at this as well.
Comment #7
sam152 commentedAs discussed the configForm option would be similar to the pattern used by field formatters, but it does increase the size of the interface and is potentially out of scope for the core API. If the UI can derive a suitable form without having to change the interface perhaps that's better?
Comment #8
sam152 commentedThis still needs a large amount of work and isn't ready for a full review. Implementation details in TypedConfigManager are causing huge headaches. The rabbit hole is deep on this one...
A more complex schema def is attached (core.entity_view_display.*.*.*).
Comment #9
sam152 commentedUsing the 'Add another' on a less insane definition:
Comment #10
sam152 commentedReady for a review, still a bit to do but improvements need to be made to the plugin manager first.
Comment #11
benjy commentedThis is looking good, some feedback below, all pretty trivial. That unique ajax id problem is interesting, I'd like to take a closer look at that before committing.
Left over debug code.
Lets put "root" into a constant?
Did we want to open a new issue for this @todo? Otherwise we can remove it.
s/to/for
$schema can be typehinted as an array.
$context sounds like an array from the param docs but then it's used as the key in $form[$context] ?
s/$deta/$delta
$this->t('Add another")
Missing space.
Thanks again!
Comment #12
sam152 commentedThanks for the review! I have replaced the @todo’s with actionable tasks which can be turned into issues, as opposed of whinges. I've also implemented the feedback.
Feel free to put some time against the AJAX keys. Like the code mentions it works for the most complicated example I could find in core, but I could probably create a test case that breaks it at well. I think a webtest will have to do given it involves the AJAX system. Happily a phase 2 improvement for me though.
Comment #13
benjy commentedI tested this with migrate_ui and I got a fatal error:
ResponseText: Recoverable fatal error: Argument 1 passed to Drupal\migrate_api\SchemaFormBuilder::processSchema() must be of the type array, object given, called in /var/www/app/modules/migrate_api/src/SchemaFormBuilder.php on line 79 and defined in Drupal\migrate_api\SchemaFormBuilder->processSchema() (line 95 of /var/www/app/modules/migrate_api/src/SchemaFormBuilder.php).PHPStorm was actually reporting the same issue to me. I think it's just a bad type-hint?
Comment #14
sam152 commentedI think you're right. I have the same patch in migrate_ui. Could it caused by an object that implements ArrayAccess? I couldn't actually reproduce this. I've attached my migrate_ui patch to compare?
Comment #15
benjy commentedAlso, i note we have some interesting side-effects here from the fact we aren't actually part of the form.
Using a global like would fail if we used this service to build two forms on the same page?
Comment #16
sam152 commentedI believe the static can be reset as getFormArray is called. That would prevent any conflicts.
Comment #17
sam152 commentedFixes discussed.
Comment #18
sam152 commentedTestbot?
Comment #19
sam152 commentedComment #21
sam152 commentedComment #28
benjy commentedWhat happens if you run that command locally, does run-tests.sh pick them up?
Comment #30
benjy commentedThe patch in #19 still has the following issues for me:
ResponseText: Recoverable fatal error: Argument 1 passed to Drupal\migrate_api\SchemaFormBuilder::processSchema() must be of the type array, object given, called in /var/www/app/modules/migrate_api/src/SchemaFormBuilder.php on line 87 and defined inOnce that's resolved i'm just going to commit this and see if we can get the tests to run that way.
I was going to fix these on commit but since we need a re-roll anyway, you may as well include them in the patch.
Missing backslash.
Missing param types.
I was getting undefined indexes on schema label for some forms.
Missing param types.
Missing param types.
throughout*
Missing backslash.
Missing type.
Comment should be first.
Comment #31
sam152 commentedComments from #30 attached.
Comment #32
benjy commentedGoing to commit this now.
Comment #35
benjy commentedThe tests passed locally, the bot still seems to be having issues with them though, not sure why. If they don't pass on HEAD within 24hrs, i'll create a testbot issue.
Comment #36
benjy commentedFinally a green build: https://dispatcher.drupalci.org/job/default/49575/console
Seems you just have to commit it the first time you add tests, same as when you add new module dependencies.
Comment #37
sam152 commentedAh, useful to know. Thanks for the reviews + commit. Will look at the integration aspect for migrate_ui, but if you get to it before me, go right ahead with it.