Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There are three types of buttons supported in core and in the Seven style guide. Standard, primary, and danger.
It's important that the correct button types are used consistently throughout Drupal
Remaining tasks
Write UI documentation on when and why to use each button type. Drupal's UI standards page would work for now until #2102191: Discuss the availiable solutions to document the Seven style guide is resolved.Audit all forms in core, building a list of incorrect button types.- Fix them
Test pages
- Views modal forms. To reproduce: admin/structure/views/view/content > edit any field
- Delete a view form. To reproduce: admin/structure/views/view/content/delete. I would suggest to use the "danger" button for the "Delete"/submit action to avoid accidentally deleted views.
- Edit image styles effects form. To reproduce: admin/config/media/image-styles/manage/xx/add/image_crop.
- Manage permissions form. To reproduce: admin/people/permissions.
- Install new theme form / update form. To reproduce: admin/theme/install
- Extend/modules page. To reproduce: admin/modules
Comment | File | Size | Author |
---|
Comments
Comment #1
LewisNymanI've updated the guidance on button in the UI guidelines: https://drupal.org/node/1850248
Comment #2
LewisNymanComment #3
ckrinaWorking on that.
Comment #4
ckrinaTo change:
Not sure, to discuss:
Comment #5
LewisNymanWe discussed this in person but current there are situations where we have action links that look like primary buttons but we also need a primary button for the main form on the page. This is a bit of weird use case at the moment.
Comment #6
ckrinaHere is the patch for the following forms:
Comment #7
ckrinaUpdating status.
Comment #9
LewisNyman6: 2166473-correct-button-types-6.patch queued for re-testing.
Comment #10
LewisNymanLove this patch! It's so nice to fix these pages. Hopefully it will pass this time.
While clicking around I found some more pages. Let's try and keep these patches small #2229157: Add correct button types to account settings forms
Comment #12
ckrinaI'm sorry, but I do not have time to work on it. I hope someone can take it over. Unasigning.
Comment #13
ckrinaRerolled patch.
Comment #14
ckrinaHere the file!
Comment #16
ckrinaTrying again.
Comment #17
ckrinaComment #18
LewisNymanHey, I tried this out and the delete confirmation form now seems to stay on an endless loop?
Comment #20
LewisNymanComment #21
ckrinaUnassigning that one to let someone with time to work on that.
Comment #22
lauriiiComment #23
lauriiiI rerolled patch to PSR-4 and fixed failing tests.
Comment #24
LewisNymanI've updated the issue summary with the test pages.
Comment #25
daviddemello CreditAttribution: daviddemello commentedComment #26
daviddemello CreditAttribution: daviddemello commentedImages of before/after states are attached.
The case "Install new theme form / update form. To reproduce: admin/theme/install" is throwing an error at the moment, so no after picture is possible.
Comment #27
cachee CreditAttribution: cachee commentedTest steps:
1. Downloaded the latest version of D8
2. Verified the buttons were incorrect for the following:
• Views modal forms. To reproduce: admin/structure/views/view/content > edit any field
• Delete a view form. To reproduce: admin/structure/views/view/content/delete. I would suggest to use the "danger" button for the "Delete"/submit action to avoid accidentally deleted views.
• Edit image styles effects form. To reproduce: admin/config/media/image-styles/manage/xx/add/image_crop.
• Manage permissions form. To reproduce: admin/people/permissions.
• Install new theme form / update form. To reproduce: admin/theme/install (could not access the link to load modules/themes from the drupal install)
• Extend/modules page. To reproduce: admin/modules
3. Performed the following tests:
• Created a views and field: the buttons were good
• Managed permission button was good
• Extend a module: button was good
4. The following button did not work:
• Update image style option button css missing
• Could not access the admin/theme/install page due to a core issue InvalidArgumentException: No check has been registered for access_check.update.manager_access in Drupal\Core\Access\AccessManager->loadCheck() (line 384 of C:\Users\Caroline\Sites\UniServer\www\d8\core\lib\Drupal\Core\Access\AccessManager.php).
Comment #28
cachee CreditAttribution: cachee commentedTest steps:
1. Downloaded the latest version of D8
2. Verified the buttons were incorrect for the following:
• Views modal forms. To reproduce: admin/structure/views/view/content > edit any field
• Delete a view form. To reproduce: admin/structure/views/view/content/delete. I would suggest to use the "danger" button for the "Delete"/submit action to avoid accidentally deleted views.
• Edit image styles effects form. To reproduce: admin/config/media/image-styles/manage/xx/add/image_crop.
• Manage permissions form. To reproduce: admin/people/permissions.
• Install new theme form / update form. To reproduce: admin/theme/install (could not access the link to load modules/themes from the drupal install)
• Extend/modules page. To reproduce: admin/modules
3. Performed the following tests:
• Created a views and field: the buttons were good
• Managed permission button was good
• Extend a module: button was good
4. The following button did not work:
• Update image style option button css missing
• Could not access the admin/theme/install page due to a core issue InvalidArgumentException: No check has been registered for access_check.update.manager_access in Drupal\Core\Access\AccessManager->loadCheck() (line 384 of C:\Users\Caroline\Sites\UniServer\www\d8\core\lib\Drupal\Core\Access\AccessManager.php).
Comment #29
tlilleberg CreditAttribution: tlilleberg commentedWith the latest version of d8, I can see admin/theme/install and can confirm the button was not primary before, and the patch fixes it. I don't know if it's the problem, but if you don't have the updates modules enabled you can't access the theme/install page.
The issue with admin/config/media/image-styles/manage/xx/add/image_crop is that "cancel" is a link, not a submit button in the render array, so it doesn't take the css. I tried turning it into a submit button, but then if you try to add an image-style and then cancel out, the "required" html5 attributes on 'width' and 'height' will not validate and will not let you cancel.
Some options regarding the image-styles form are:
-- Travis Lilleberg
Digital Loom
www.digital-loom.com
Comment #30
daviddemello CreditAttribution: daviddemello commentedEdited buildForm() in /core/modules/image/src/Form/ImageEffectAddForm - overriding the base class ImageEffectFormBase::ImageEffectFormBase() to output the cancel action as a submit button instead of as a link.
Thought that in the future it might be good to either change the cancel action in the base class for consistency throughout Drupal, or to provide and affordance (argument or helper function) to set the behavior of the cancel action - avoiding knowledge and repetition of the implementation when sublassing buildForm() in other places.
Comment #31
cachee CreditAttribution: cachee commentedAdded all of the button attributes to the image cancel button in the /core/modules/image/src/Form/ImageEffectAddForm.
Comment #32
cachee CreditAttribution: cachee commentedChanged the button code to not be a primary button.
Comment #33
lauriiiLooks good!
Closing should be on the next line. More about this here.
Comment #34
tlilleberg CreditAttribution: tlilleberg commentedThere's an issue with patches 31/32 in the ImageEffectsFormBase class.
To recreate:
It won't let you cancel because we've made the cancel link into a submit button and because of that, it tries to validate the form. The empty width/height prevent you from leaving.
I address this by keeping "cancel" a link and just adding the button class to it.
I also fixed the coding standard issue lauriii saw in the User Permission Form
-- Travis Lilleberg
Digital Loom
www.digital-loom.com
Comment #35
LewisNymanIt seems dangerous to change the button too much. if they aren't submit button we could just add the classes instead of using #button_type?
Comment #36
lauriiiIf there's no tests for this, we should extend the tests to cover this.
Comment #37
tlilleberg CreditAttribution: tlilleberg commentedJust to be clear, with patch 33, the cancel button is *not* a submit button. I did what Lewis suggested and left it a link and simply added the 'button' class to it. That was the only cancel button we created. All the rest of the altered buttons should be submit actions.
So @Lewis, patch 33 should do what you suggested, but I can definitely update it if you find something else that needs fixing.
I can work on the test if nobody beats me to it, but that'll take a little longer.
Comment #38
LewisNyman@tlilleberg Yes, I think the problem is in the views delete form?
Comment #39
LewisNymanComment #40
LewisNymanComment #41
LewisNymanThis issue has stalled because of one difficult problem on one page. I think the best thing to do here is to split this up into separate issues for each page, these can be nice novice tasks for Dev days
Comment #42
LewisNymanI'm setting this issue to active as it is now a meta issue without the need for any patches. All the patches can be submitted and discussed in the individual issues:
#2469889: The modules page doesn't have a primary button
#2469911: The edit image styles form's cancel link should be styled a a button
#2469917: The install new theme page doesn't have a primary button
#2469921: The appearance page doesn't have a primary button
#2469929: The confirmation forms' cancel link should be styled as a button
#2469939: The permissions page doesn't have a primary button
Comment #43
joelpittetComment #44
pingwin4egThere's another one issue: #2630162: The Edit URL Alias form buttons should be styled in consistency with other buttons
Comment #51
pingwin4egAll child issues had been fixed a long time ago.