Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In 7.x we implemented hook_field_extra_fields() to allow the scheduler fieldset to be exposed in the content-type 'manage fields' tab, so that admins could adjust the position in the form.
This code was removed from 8.x in this commit. However, we still need this functionality in 8.x and it is still available - the hook has been renamed hook_entity_extra_field_info(). The core issue which changed it to entity API is #2225629: Move hook_field_extra_fields() to the entity API and here is the change record for extra field definitions and the hook_entity_extra_field_info() API page
Comment | File | Size | Author |
---|---|---|---|
#9 | 2667692-9.extra_field_info.patch | 3.8 KB | jonathan1055 |
|
Comments
Comment #2
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHere is the function, converted to the new hook and updated for 8.x.
I think this should also have test coverage too, which I will work on, but for now here's the function, for review and comment.
Comment #4
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedI have added a second set of tests to FieldsDisplayTest to check that the weight item is shown on the form when it should be and not shown when it shouldn't. This patch contains just the changes to the test file, so there should be an extra failing class now.
Comment #6
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedAs expected we get a new class fail
Next I'll provide a patch with the tests and fixed code.
Comment #7
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedPatch with new test + fixed .module
Comment #9
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedI realised that there is no need to only allow the weight entry for 'fieldset'. So
simply becomes
If this restriction is removed then the weight setting works for vertical tabs too, which is better. New patch, including tests.
Comment #10
pfrenssenI don't remember why I deleted this, apparently I thought this was no longer used since we are now using base fields. I possibly thought all the relevant code was already factored out of it and this was just the wrapper. But yes we obviously still need it.
Thanks for adding test coverage, this will ensure I will not mess with it any more in the future :)
Also very very nice to see a fully green test. Amazing work!!
Good idea!
Thanks for adding this documentation, that clarifies why we need it.
Still using the old array() syntax. This is OK since it is consistent with the remainder of the module file. We should maybe do a cleanup to convert all of these when we are closer to release.
This surprised me. This should override the static from SchedulerTestBase, so logically the Node module and Scheduler itself should no longer be enabled now. But since the tests are green this seems to work.
I looked into it and this is handled by
WebTestBase::installModulesFromClassProperty()
. It loops over all parent classes and merges the properties together. Nice trick, I didn't know this.There is the
@covers
keyword now, but I'm not sure if this applies to WebTestBase as well. It does apply to PHPUnit based tests. It's fine to leave it for now.Looking good, RTBC!
Comment #12
pfrenssenCommitted to 8.x-1.x. Thanks!
Comment #13
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi Pieter,
Thanks for all the review info above.
2. Yes we could do an array syntax cleanup. Let's pick a time when we have only a few patches waiting review, as it is bound to cause many re-rolls.
3.
SchedulerTestBase loads the standard modules ...
I discovered this by chance, checked it, then I cleaned up the other test files, removing the unnecessary lines. I added the comment specifically to say way, and share the knowledge. Thanks for looking deeper into the reason.4. I did not know about
@covers
and will use it in future test coding.Yes, it is very good to see the full set of green test passes. In addition to being "a good thing" in itself, it also makes our development/review/retest process cleaner and easier, and the issue status properly reflects the state of the submitted patch .