Problem/Motivation
https://www.drupal.org/project/field_readonly is a module which alters each entity form, to disable some of the form fields.
It used to have hook_field_attach_form for that.
Sadly there is no such hook in Drupal8, though there is \Drupal::moduleHandler()->alter('entity_display_build', $build_list[$key], $context);
Proposed resolution
Add \Drupal::moduleHandler()->alter('entity_form_build', $form, $context); into \Drupal\Core\Entity\Entity\EntityFormDisplay::buildForm
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | drupal-module-alter-entity-form-build-2691723-1-8.patch | 660 bytes | swim |
Comments
Comment #2
swim commentedHere's a patch that addresses the issue outlined in the summary.
Comment #3
dawehnerSome kind of test coverage would be nice, I think.
Comment #4
swim commentedHey dawehner,
I'm sorry but I don't know the most appropriate location to write the test coverage. Because Entity is not a module should the test coverage live in core/modules/system/src/Tests/Common/AlterTest.php?
Comment #5
dawehnerFor
hook_entity_display_build_alter()we havecore/modules/field/tests/src/Kernel/DisplayApiTest.php:156currently, so maybe opening up a FormDisplayTest in there would be the right way. ON top of that then add something like\field_test_entity_display_build_alterfor your new hook maybe.Note: We also have to add documentation to
entity.api.phpComment #6
swentel commentedHmm, same as #2640056: Contrib modules can't alter the building of entity form displays - one of them should be marked duplicaget
Comment #7
swentel commentedClosing in favor of #2640056: Contrib modules can't alter the building of entity form displays (because it's older)