public static function disableButtons(array $element) {
    if (isset($element['#type'])) {
      $element['#access'] = !in_array($element['#type'], [
        'button',
        'submit',
        'image_button',
      ]);
    }

    // Recurse into child elements.
    foreach (RenderElement::children($element) as $key) {
      if (is_array($element[$key])) {
        $element[$key] = static::disableButtons($element[$key]);
      }
    }
    return $element;
  }
public static function disableButtons(array $element) {
    if (isset($element['#type'])) {
      $element['#access'] = !in_array($element['#type'], [
        'button',
        'submit',
        'image_button',
      ]);
    }

    // Recurse into child elements.
    foreach (RenderElement::children($element) as $key) {
      if (is_array($element[$key])) {
        $element[$key] = static::disableButtons($element[$key]);
      }
    }
    return $element;
  }
public static function disableButtons ( array $ element ) { if ( isset ( $ element [ '#type' ] ) ) { $ element [ '#access' ] = ! in_array ( $ element [ '#type' ] , [ 'button' , 'submit' , 'image_button' , ] ) ; } // Recurse into child elements. foreach ( RenderElement :: children ( $ element ) as $ key ) { if ( is_array ( $ element [ $ key ] ) ) { $ element [ $ key ] = static :: disableButtons ( $ element [ $ key ] ) ; } } return $ element ; }
Pre-render function to disable all buttons in a renderable element.

@param array $element
The renderable element.

@return array
The renderable element with all buttons (at all levels) disabled.
Pre - render function to disable all buttons in a renderable element .