- Issue created by @jastraat
- πΊπΈUnited States jastraat
I'm attaching a patch that does the most minimal job of making section library templates fieldable. It adds no new routes and uses the entity collection route as the base for managing the field UI. It adds no new classes or menu items and does not add fields to section_library's custom "add to library" forms.
This also doesn't include an update hook for sites that already have section_library installed; that would be a good enhancement.
However, with this patch in a site installing section_library for the first time, the following are true:
- Add additional fields to section templates at /admin/content/section-library/fields
- Manage the edit form display and the edit form (which is more content entity vanilla) will display all the fields as you have configured them.
Users could alter the add to library forms using route subscribers to define their own form classes or with form alter hooks to add fields as desired to those forms.
Future enhancements could include:
- Altering the add to library forms so that they automatically include the custom fields
- Adding an entity type update hook for sites already using section_library
- Status changed to Needs review
9 months ago 3:04pm 19 April 2024 - Open on Drupal.org βCore: 10.2.1 + Environment: PHP 8.1 & MySQL 8last update
9 months ago Waiting for branch to pass - πΊπΈUnited States jastraat
The latest MR also converts the image field to a true image field which allows for applying image form options for example. Note: this is another change that requires an entity update.
- Open on Drupal.org βCore: 10.2.1 + Environment: PHP 8.1 & MySQL 8last update
9 months ago Waiting for branch to pass - πΊπΈUnited States jastraat
Attaching a patch reflecting the current MR. This adds an update and post update hook to make the image field a true image field, make templates fieldable, and update existing instances of template content.
The only thing that I have not included yet is updating the template collection view to use an image field in a post update hook.
- πΊπΈUnited States jastraat
Added a post update hook to update any views using the section library template image field.
- πΊπΈUnited States tlilleberg
I created a blank Drupal install, enabled section_library and confirmed it was working as intended.
Then I applied the patch. Afterwards the sections I added to the library were still displaying correctly in the admin page on in LB. I was able to still apply section libraries successfully.
I then added a simple text field to Library Template entities and was able to edit and save data into the new field.
section_library_fieldable-3442106-9.patch works with no issues.
- πΊπΈUnited States jastraat
Attaching a patch with the most up to date code from the merge request.
- π―π΄Jordan Rajab Natshah Jordan
I really like this new feature!
I see the new logic and feature being added to a new major branch,2.0.x
, to avoid causing issues for the 5,706 sites currently using the module.
Alternatively, it could have a smart and smooth update process. - πΊπΈUnited States jastraat
This does have an upgrade path to convert the existing entities and any views (likely just the one) that were using the file (now image) field. It might make sense to do a 2.x branch anyway, but definitely trying to provide a smooth upgrade path!
- πΊπΈUnited States jastraat
Attaching a patch from the most recent MR. This changes the add forms so that they extend ContentEntityForm and as a result show any custom fields that have been added to the template entity.
- πΊπΈUnited States jastraat
Updated patch from latest MR to add more flexibility to the choose section controller, add a title callback to make the add form title dynamic, and fix some stylelint errors.
This MR has expanded beyond the original scope, so it makes sense to create a new branch and it needs to be re-reviewed.
- πΊπΈUnited States jastraat
One more addition - the ability to add a description to the choose section dialog.