Problem/Motivation
1: In https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/modules/ui_p...
public function build() {
$build = $this->buildComponentRenderable();
return $build;
}
public function blockForm($form, FormStateInterface $form_state) {
return $this->buildComponentsForm($form_state);
}
public function blockSubmit($form, FormStateInterface $form_state) {
$this->submitComponentsForm($form_state);
}
$form should be passed to the ComponentFormBuilderTrait methods, and/or the return of those methods should only target a key in $form and not replacing it entirely.
Not taking the provided $form into account may lead to extensibility problems if someone alters the form in other contrib or custom.
I had a problem years ago in a field formatter plugin where I had not called a parent method, it was ok in "manage display" but ot in layout builder because it was preparing additional stuff: https://git.drupalcode.org/project/file_extractor/-/commit/cf3b74dcc1312...
That's why I think not taking the provided $form into account may lead to problems.
2: In https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Form/Com...
protected function getComponentConfiguration(): array {
return $this->configuration['ui_patterns'] ?? [];
}
protected function setComponentConfiguration($configuration): void {
$this->configuration['ui_patterns'] = $configuration;
}
...
I think the "ui_patterns" key should be transformed into an argument, in case a form needs multiple component form elements.
3: In https://git.drupalcode.org/project/ui_patterns/-/blob/2.0.x/src/Form/Com...
public function buildComponentRenderable($component_id = NULL, $source_contexts = []) {
This method is used for rendering, the trait is named ComponentFormBuilderTrait, maybe it should be placed in another trait? I understand that it is there because it is using the common method "$this->getComponentConfiguration()".
Proposed resolution
Remaining tasks
API changes
Issue fork ui_patterns-3444770
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pdureau commentedComment #3
pdureau commentedComment #4
pdureau commentedTo have a look
Comment #5
christian.wiedemann commented1. This is done wrong in Block Source which we propably remove.
2. I am not sure about that. Actually I think it is good to have allways the same key in every consumer. We may provide a getConfigurationKey() function to overwrite that? Should we? @pdureau @Grimreaper
3. Should we provide an own trait for that? I would vote for that- @pdureau @Grimreaper
Comment #6
christian.wiedemann commentedComment #7
pdureau commentedWe have an issue about that: #3460784: [2.0.0-beta1] Blocks implementing PluginFormInterface don't work with BlockSource
We will not remove BlockSource but introduce a whitelist.
No opinion. I assign to @Grimreaper
Comment #9
grimreaperHi,
1. Now that BlockForm return $form that is passed to it, no problem.
2. I opened a MR with a POC of what I had in mind and with current codebase. I have just edited the files, not tested. This can be used to discuss.
3. Vote for a new trait too.
Comment #10
pdureau commentedComment #11
christian.wiedemann commented@Grimreaper I tested your code and add the configuration_id to all places. From my point of view it should work now. (But we realy need e2e tests now)
Comment #12
christian.wiedemann commentedComment #13
pdureau commentedFlorent, can you have a look?
Comment #14
grimreaper@Christian.wiedemann,
Thanks for the update.
I put some code review comments.
Also point 3, creating a new trait remains to be done.
Comment #15
christian.wiedemann commented@Grimreaper I updated/fixed your comments. We decided to no implement an own trait for rendering because they belong somehow together. Thanks!
Comment #16
christian.wiedemann commentedComment #17
pdureau commentedComment #18
grimreaperHi,
@Christian.wiedemann, thanks for your work. Ok for me now.
I have rebased and removed the todo.
You can give a last review in case my rebase broke stuff.
Comment #20
christian.wiedemann commentedRebase was the hell. So I created a merge branch and opened a pull request. I tested Views Layouts and Field formatters. We should merge it.
https://git.drupalcode.org/issue/ui_patterns-3444770/-/tree/3444770-2.0....
Comment #21
pdureau commentedHi Christian,
So, this one? https://git.drupalcode.org/project/ui_patterns/-/merge_requests/180
I am not very comfortable about opening a new branch, instead of doing the rebase. I guess rebase was hell because it was done late. So, I will ash @grimreaper to have a look, because I don't feel competent enough in this subject.
However, before that, it seems phpstan check has failed: https://git.drupalcode.org/project/ui_patterns/-/jobs/2407677
Can you run the checks locally before pushing?
Also, there is one commit more to rebase from 2.0.x
Comment #22
pdureau commentedToo late for beta1. Moved to beta2
Comment #23
pdureau commentedComment #24
christian.wiedemann commentedComment #25
christian.wiedemann commentedI rebased to the latest 2.0.x. Check the merge branch.
Comment #26
pdureau commentedComment #28
grimreaperMerged.
Thanks!
Comment #29
pdureau commented