- Issue created by @jesss
The Block config form for the Google AdSense block includes a number of conditional fields that are controlled by the #states array. This works as expected in the core Block Layout UI. However, those conditions are ignored when the form is accessed via Layout Paragraphs.
Specifically, the Width, Height, and Layout Key form elements should not be visible or enabled unless the Ad Format form element is set to "Custom."
Screenshot of the form in the Blocks UI:
Screenshot of the form in the Layout Paragraphs UI:
Example of the form array for the Height field as provided by the Google AdSense module:
$form['ad_height'] = [
'#type' => 'number',
'#title' => $this->t('Height'),
'#default_value' => $this->configuration['ad_height'],
'#description' => $this->t('Custom ad height.'),
'#field_suffix' => ' ' . $this->t('pixels'),
'#size' => 3,
'#maxlength' => 4,
'#min' => 50,
'#max' => 1200,
'#states' => [
'enabled' => [
':input[name="settings[ad_format]"]' => ['value' => 'custom'],
],
'visible' => [
':input[name="settings[ad_format]"]' => ['value' => 'custom'],
],
'required' => [
':input[name="settings[ad_format]"]' => ['value' => 'custom'],
],
],
];
Active
2.1
Code