Problem/Motivation

The information about text formats is a drupalism and most of the sites end up hiding that bit of information. Drupal 8 makes it a little more hard to hide so it might not be trivial to do.

Proposed resolution

- Add '#format_hide' property for the text format element.
- Expose this as an option for textarea widgets which support the #text_format type.

Remaining tasks

User interface changes

Adding a checkbox in manage form display to hide text formats.

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

serundeputy’s picture

I think this is just permissions.
Create a user role say 'author' and give them permission to create 'Article's but not permissions to change text formats.

or is this not what you mean? It works for me see screenshots.

swentel’s picture

Assigned: Unassigned » swentel

It's not a persmission afaics. The outcome is to just hide the information about text formats, but allow access to say Filtered HTML to which the current user has access and is configured as default. Not many people really read those pages about the text formats.

I'd be fine hiding them, should be an easy patch.

Peter Majmesku’s picture

Would be good to have the feature. That way the form would be easier for the editorial board. How is the status here, will this be done?

swentel’s picture

Version: 8.0.x-dev » 8.1.x-dev
Assigned: swentel » Unassigned
Category: Task » Feature request
Status: Active » Needs review
FileSize
2.05 KB

This seems to work.

Status: Needs review » Needs work

The last submitted patch, 4: 2413335-4.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review
FileSize
3.27 KB
2.05 KB

Fixing the failures

swentel’s picture

Issue summary: View changes
Peter Majmesku’s picture

Thanks for the fast reply and your work on this feature. It's appreciated. :)

I've tried to use the following command from my Drupal 8 root directory to apply the patch

git apply patches/2413335-6.patch

Then I get the following message

fatal: corrupt patch at line 91

It's the same if I put the file into Drupal's root folder. How is it intended to apply the patch?

Peter Majmesku’s picture

Status: Needs review » Reviewed & tested by the community

I've needed an new line at the end of the path file to be able to apply the patch (Drupal 8.0.3). Afterwards the patch works - it does what I need: the admin can choose text formats and the user with the editor role does not see a drop down field for choosing the input format. Thanks.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +D8 upgrade path

This looks to me like it will need an update to re-save existing config with the new default value, otherwise it'll show up in diffs etc.

Also couple of questions:

1. I'm assuming when a user only has access to a single format that this hides just the filter tips?

2. Do we really want to hide text formats from users with 'administer formats' permission or similar?

3. Extension of #2... Do we really want to hide this when the format selected for existing content is not the default? I'm thinking of existing sites (like Drupal.org) where there might be old content in an old format, the default was changed, and people might want to switch it to the new format manually when editing. You might still want to hide this for new content, but making it impossible to change the format of old posts is a bit tricky.

I don't know the answer to those questions - agreed that this makes forms look crufty, but also wondering a bit whether we couldn't de-emphasise the existing element a bit more in general - like just the '?' icon for filter tips.

catch’s picture

Issue tags: +Usability
swentel’s picture

1. That's what #2544188: Change the label "About text formats" if only one format is available is doing, we can always merge it in there
2. Good question, and I think we should actually show it indeed. I've run into situations where I wanted to change it but couldn't because of an annoying #access => FALSE thing
3. Fair question. If we do 2, then it's at least half covered. Also, since this is opt-in, it shouldn't be a problem when deploying on an existing site either, so we're getting away with it - for now.

And yes, needs an upgrade path to update the entity form displays.

Peter Majmesku’s picture

My feedback to this issue as a reply to #10 (and #12).

1., If there's already an issue for this seperated topic, we could keep it seperated.
2., It would be good to have a possibility to make the text formats available if the user has the permission. But there can be situations, where you as a admin don't like this text formats dropdown and don't want to see it anyway. If you're an admin, you have "all" permissions. Maybe a "checkbox"-option in configuration would be nice for this case or just an option in the yaml config.
3., If you have old content, the last defined input format could be the default one. For new content, the defined text format for the field could be the default one.

Peter Majmesku’s picture

Note about the patch: the text formats dropdown is still visible in node forms, which were created with devel generate module.

swentel’s picture

Also, I've been testing this code a bit in a custom project, and I think it's actually wrong anyway, especially if there's an editor: then the editor is completely gone too - but I'll double check (because I'm using a variant where I swap out the process of the default textFormat class with my own)

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.

jonathanshaw’s picture

hchonov’s picture

Issue tags: +DevDaysMilan

@swentel just by looking at the code you could see that if using an editor it will be gone if the new setting is used because setting $element['format']['#access'] to FALSE and putting the editor in $element['format']['editor'] would not work, instead the editor should be placed somewhere else, but not under $element['format'].

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.

quietone’s picture

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.

larowlan’s picture

Status: Needs work » Postponed

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.

james.williams’s picture

Update:

#784672: Allow text field to enforce a specific text format allows hiding the text format information, when only one format is allowed to be used for the text_format element.

But it leaves the 'About text formats' link behind. #2544188: Change the label "About text formats" if only one format is available is looking at improving the UX when that shows without the format selector.

None of these cover the possibility of hiding the 'About text formats' link altogether (whatever it might get labelled). I guess this issue might probably still be need to wait for that latter issue to be resolved though.

jonathanshaw’s picture

I think that

1. the scope of the current issue is unclear, whether it is referring to the text format selector or the text format information link

2. hiding the link but not the selector is not a 95% use case and should not be a core option

3. this issue should be about giving the option to hide both the selector and the link together, which is relevant if:
- a. the default format is different for different users, but you don't want them to choose
- b. only a single format is allowed, so no selector is shown, but you still want to hide the link

4. even with this reduced scope, I have doubts about whether this is a common enough use case for this setting to belong in core

jonathanshaw’s picture

Status: Postponed » Needs work

I don't think it should be postponed, if it should be open at all. It's independent of the issue of the link's wording.

james.williams’s picture

Status: Needs work » Closed (won't fix)

Yeah I think I’m inclined to agree. Even if there is an outstanding feature that could be implemented, it’s possibly for too narrow a use case, and so not worth supporting in core.

The work already done in core to allow configuring allowed text formats, plus the possible relabelling, could be sufficient for core.

I’m going to be brave and just close this issue - it can always be reopened if there really is enough support for it, though it’s scope would then need clarifying.

Pierre Paul Lefebvre’s picture

For people finding this issue from popular search engines, the work is now happening in https://www.drupal.org/project/drupal/issues/3323007