Problem/Motivation

\Drupal\path\Plugin\Field\FieldWidget\PathWidget::formElement currently hardcodes the description:

      '#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),

Proposed resolution

Pull the description from the \Drupal\Core\TypedData\DataDefinitionInterface::getDescription but fall back to the current value.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 2842047-2.patch1.28 KBnaveenvalecha

Comments

dawehner created an issue. See original summary.

naveenvalecha’s picture

StatusFileSize
new1.28 KB

Initial patch. Let's push media initiative by patch a day.
// Naveen

naveenvalecha’s picture

Status: Active » Needs review
tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

To me personally this doesn't seem worth writing a test for. It would require adding two new test entity types, and the new trend seems to be not to add them to entity_test directly, but in fact add a whole new test module just for that. So it seems like a whole lof of work for not that much benefit.

Of course this is not up to me in the end, but setting RTBC due to the above.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 2: 2842047-2.patch, failed testing.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests
+++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
@@ -44,6 +44,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
+    $alias_description = $this->fieldDefinition->getDescription();
+    $alias_description = $alias_description ?: $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.');

Given that we are adding logic I'm not sure that not having a test is a good thing. If we don't have a test then this could be easily broken.

naveenvalecha’s picture

Assigned: Unassigned » naveenvalecha

Assigning to myself for tests

gábor hojtsy’s picture

Issue tags: +D8Media
+++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
@@ -44,6 +44,8 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
+    $alias_description = $this->fieldDefinition->getDescription();
+    $alias_description = $alias_description ?: $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.');

Can we set default field descriptions in default config as well. In which case we can also just remove this fallback maybe and just rely on the field description?

Maybe that would be a BC break in which case I understand the fallback but its counter-intuitive and may lead to strange bugs, eg. you want to remove the description by entering nothing or removing what you entered for the field but it then makes this built-in thing disappear. That sounds to me like a usability WTF.

So I think we would rather remove this fallback entirely. Its a very tiny BC break to pay for evident behavior in the future :)

alexpott’s picture

Forms are specifically excluded from the BC promise. So I'm not sure where the BC break is - what this does mean is that you need an upgrade path.

gábor hojtsy’s picture

@alexpott: well this is both form and config :) Its a form driven by config. If the fallback is not there, existing fields will not have the description unless we have an upgrade path. The question is how can we find what needs an upgrade path. Eg. how do base fields altered in get this?

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!

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.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Needs work

Still seems valid.