Olivero's form alter assumes "submit" will be the key for the submit button in an actions element

Created on 27 March 2021, about 4 years ago
Updated 14 April 2025, 10 days ago

Problem/Motivation

Discovered when working with #3174107: Add additional testing coverage for Olivero β†’ .

The theme assumes $form['actions'] will have a button keyed submit. That may not be the key name of the submit button and the class is not attached. As seen in olivero.theme:

/**
 * Implements hook_form_alter() for adding classes and placeholder text to the search forms.
 */
function olivero_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  if (isset($form['actions']['submit']) && (count($form['actions'])) <= 2) {
    $form['actions']['submit']['#attributes']['class'][] = 'button--primary';
  }
}

Steps to reproduce

Given

        'actions' => [
          'continue' => [
            '#type' => 'submit',
          ],
        ],

You receive

        'actions' => [
          'continue' => [
            '#type' => 'submit',
          ],
          'submit' => [
            '#attributes' => [
              'class' => ['button--primary']
            ],
          ]
        ]

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: won't fix

Version

11.0 πŸ”₯

Component

Olivero theme

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
  • Usability

    Makes Drupal easier to use. Preferred over UX, D7UX, etc.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024