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

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: Hide the link "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.