Problem/Motivation
A form in a block has an incomplete class name. In the example below, it is js-form-item- and form-item-.
<div class="js-form-item form-item js-form-type-item form-type-item js-form-item- form-item-"><label>Balance</label>500 NOK</div>
Steps to reproduce
Block Code:
<?php
namespace Drupal\xxxxxxxx\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'Modal' Block
*
* @Block(
* id = "modal_block",
* admin_label = @Translation("Modal block"),
* )
*/
class ModalBlock extends BlockBase {
public function build() {
$form['balance'] = [
'#type' => 'item',
'#title' => 'Balance',
'#markup' => '500 NOK',
];
return $form;
}
}
BlockBase Render un-expected class 'form-item-'
<div class="js-form-item form-item js-form-type-item form-type-item js-form-item- form-item-"><label>Balance</label>500 NOK</div>
FormBase Render expected code
<div id="edit-balance" class="js-form-item form-item js-form-type-item form-type-item js-form-item-balance form-item-balance"><label for="edit-balance">Balance</label>500 NOK</div>
Issue (bug in question)
I believe, the rendered class by BlockBase is missing the [#name], since the output is form-item-
. FormBase produce expected output.
Proposed resolution
TBA
Remaining tasks
Check for duplicate
patch
review
User interface changes
API changes
Data model changes
Release notes snippet