Problem/Motivation

This is a followup issue for #1535868: Convert all blocks into plugins.

  • Currently, the block instance creation form requires that users specify a new machine name for each configured block instance.
  • This is frustrating UX because most users will not care what the block's machine name is.

block_machine_name.png

Proposed resolution

  • Put the block title field first in the form.
  • Hide the machine name field by default and automatically generate block machine names, like in the field UI.
  • The block title is probably the best source for the default machine name.

Remaining tasks

This issue is postponed on two prerequisite issues:

  1. #1884762: Block forms should use #type => machine_name
  2. #1875260: Make the block title required and allow it to be hidden
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm’s picture

Bojhan suggested just making the block title required, and instead adding a checkbox to hide it when the block is rendered. Then we get machine names for free. I think this is a good idea.

xjm’s picture

xjm’s picture

Status: Postponed » Active
Gábor Hojtsy’s picture

FileSize
24.7 KB
126.39 KB

This machine name field is confusing in various ways:

1. As stated in the issue opener, I need to enter a name, but it does not tell me what is the significance of providing a correct one. Unlike most other places (eg. vocabulary, etc.) the machine name is not automatically generated from the title of the block.

2. Although the issue opener suggests to generate the machine name based on "based on the plugin ID with a theme name and/or numerical index appended as needed", when the block is saved, it comes back with those pieces prefixed to the provided machine name. Not sure why would you want to replicate it in the machine name itself.

3. Also on that, when the machine name comes back, the value contains a prefix such as "plugin.core.block.bartik." before the value that I entered. This looks very puzzling given the description for the field stating the value *should not possibly have dots in it*: A unique name to save this block configuration. Must be alpha-numeric and be underscore separated. So the value I entered gets transformed, is not editable anymore and does not follow the rules of how it should be (vs. user docs):

Blockdots.png

4. The field is prominently placed high above in the form and is always visible (even after specified, even though not editable). Non-editable values are displayed elsewhere (such as in the field config forms) as regular form #item values, not disabled fields. Also, the prominence of the machine name tells me the value of it is significant to know for me, but I cannot figure out any reason why it would be:

Blockname.png

Compare this with machine names on a vocabulary which gives the name the visual important it actually has (even though it actually lets people edit the machine name):

Vocabularyname.png

Gábor Hojtsy’s picture

FileSize
38.49 KB

Additional image for previous comment.

xjm’s picture

Status: Active » Postponed

See #1. We're now planning to make the title required and add a checkbox to show or hide it #1875260: Make the block title required and allow it to be hidden. Then, the title can be used as the basis for the machine name, and we can replace it with a machine name field like we use for taxonomy, fields, etc. Marking postponed on that issue for clarity.

Gábor Hojtsy’s picture

I assume we'll still need to resolve not displaying the full CMI name back, but keeping it as-is it was entered or calculated earlier to conform with the machine name guidelines.

xjm’s picture

Re: #7: Yeah, I agree. I also repeatedly found myself wanting a separate property or method to get the machine name out of the config ID when I was developing. This isn't precisely the same as #1760358: Provide a way to extract the ID from a config object name because as far as config is concerned, plugin.core.block is the base of the name and theme.machine_name is the unique ID (though actually @timplunkett and @EclipseGc implied yesterday that the theme will be going away from the name eventually because the display will store the instances it wants, removing the need to load by theme name.)

xjm’s picture

This patch will also be simpler with #1884762: Block forms should use #type => machine_name going in first. As @tim.plunkett points out in that issue, that part of this issue's scope is non-controversial. So let's postpone on that as well as the title visibility issue.

xjm’s picture

Issue tags: +Block plugins
webchick’s picture

Priority: Normal » Major

This is really, really terrible UX. Escalating to major.

Gábor Hojtsy’s picture

Status: Postponed » Active

Now that #1884762: Block forms should use #type => machine_name landed, what should be done here?

webchick’s picture

Priority: Major » Normal
Status: Active » Postponed (maintainer needs more info)

I don't actually know. It seems like it's doing this already? What am I missing?

tim.plunkett’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Ah! In #1820834: Change #type machine_name default 'source' element to 'label', the default was switched from 'name' to 'label'. So we didn't need anything more than #1884762: Block forms should use #type => machine_name after all.

tim.plunkett’s picture

Issue summary: View changes

Updated issue summary.