Problem/Motivation

There are way too many theme functions / template files in core. Some are similar (if not identical) and should be consolidated.

Proposed resolution

We have two options:

  1. Remove theme_radios() and call theme('container') instead (build a render array with '#theme' => 'container')
  2. If we really do need a separate preprocess function for this, let's use theme('container__radios') instead of theme('container') and add all our preprocess magic into template_preprocess_container__radios()

Remaining tasks

Decide which of the 2 options above to pursue, and do it.

User interface changes

None

API changes

Removal of theme_radios

#1819284: [meta] Consolidate all form element container templates, and add theme_hook_suggestions
#2041845: Remove theme_checkboxes() and call theme('container') instead

Comments

ericduran’s picture

Assigned: Unassigned » ericduran

Patch coming

ericduran’s picture

Status: Active » Needs review
StatusFileSize
new2.28 KB

Still waiting for local test to finish but so far seems like no test changes are needed.

Two things:
- Change radios element theme_wrapper from theme_radios to theme_container.
- Added a new class to theme_container so it'll generically add the form- {form-type} class.

ericduran’s picture

StatusFileSize
new3.09 KB

Fixing issues with extra attributes such as #disable getting passed in to the container.

The last submitted patch, 2041825-Remove-theme_radios-3.patch, failed testing.

dsnopek’s picture

Status: Needs work » Needs review

#3: 2041825-Remove-theme_radios-3.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 2041825-Remove-theme_radios-3.patch, failed testing.

Anonymous’s picture

Issue summary: View changes

related

manuel garcia’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new2.41 KB

#2152221: Convert theme_radios() to Twig got in.

Attached a patch which:

  • Gets rid of temeplate_preprocess_radios
  • Gets rid of radios.html.twig file,
  • Changes its #theme_wrappers to container.

Looking at the patch on #3, theme_container was moved into template_preprocess_container - not sure we need to do anything extra in the preprocessor anymore? classes etc?

Status: Needs review » Needs work

The last submitted patch, 7: 2041825-Remove-theme_radios-7.patch, failed testing.

SebCorbin’s picture

Status: Needs work » Needs review
StatusFileSize
new4.49 KB

Difference on Radio (single)

-         <div id="edit-radios-single" class="form-radios fieldgroup form-composite"><div class="form-item form-type-radio form-item-radios-single form-disabled">
+         <div disabled="disabled" class="fieldgroup form-composite form-wrapper" id="edit-radios-single"><div class="form-item form-type-radio form-item-radios-single form-disabled">

Added this code in template_preprocess_container() but it seems wrong to me


  // Disabled attribute is handled on children
  unset($element['#attributes']['disabled']);
quicksketch’s picture

Status: Needs review » Needs work
-    '#theme_wrappers' => array('radios'),
+    '#theme_wrappers' => array('container'),

The replacement here should be '#theme_wrappers' => array('container__radios'),, so theme_container will be used by default but users can use the suggestion of container--radios.html.twig if they want to target radios directly.

quicksketch’s picture

This patch should also remove the entry for "radios" from drupal_common_theme().

SebCorbin’s picture

Status: Needs work » Needs review
StatusFileSize
new3.51 KB

Moved special behavior to theme_container__radios as per #10 and #11

Status: Needs review » Needs work

The last submitted patch, 12: 2041825-12-remove-theme_radios.patch, failed testing.

SebCorbin’s picture

andriyun’s picture

Assigned: ericduran » Unassigned
andypost’s picture

Version: 8.0.x-dev » 8.1.x-dev
manuel garcia’s picture

Assigned: Unassigned » manuel garcia

Rerolling...

manuel garcia’s picture

Assigned: manuel garcia » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.3 KB

Status: Needs review » Needs work

The last submitted patch, 19: remove_theme_radios-2041825-19.patch, failed testing.

manuel garcia’s picture

Markup before patch:

<!-- BEGIN OUTPUT from 'core/themes/classy/templates/form/radios.html.twig' -->
<div id="edit-status" class="form-radios">

After:

<!-- BEGIN OUTPUT from 'core/themes/classy/templates/form/container.html.twig' -->
<div data-drupal-selector="edit-status" id="edit-status--wrapper" class="fieldgroup form-composite js-form-wrapper form-wrapper">
star-szr’s picture

I don't think we can remove any theme hooks in D8, but we can probably come up with a strategy for phasing certain ones out…

manuel garcia’s picture

:'(

star-szr’s picture

Backwards compatibility!

manuel garcia’s picture

Heheh I understand - only sorry I didn't put more time into this at the time =)

andypost’s picture

Any idea how to make it BC way?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

smustgrave’s picture

Wanted to bump this one more time if still needed.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.