If a prop has multiple allowed types, the SDC Styleguide form throws an error:
Create a component with a prop that has multiple allowed types.
e.g.:
name: Card
status: stable
description: Card with optional image
props:
type: object
properties:
heading:
type: string
title: Heading
description: Heading for this card
text:
type: ['string','null']
title: Text
In SDC Styleguide 1.1 this throws an error only for the components that have props with multiple allowed types.The error is:
TypeError: Cannot access offset of type array on array in Drupal\sdc_styleguide\Form\SDCDemoForm->buildForm() (line 97 of modules/contrib/sdc_styleguide/src/Form/SDCDemoForm.php).
I fixed this by changing that section of the Form code to this:
// If there are multiple types, just use the first one
if (is_array($settings['type'])) {
$prop_type = reset($settings['type']);
}
$form['component']['fields'][$field] = [
'#description' => $settings['description'],
'#required' => in_array($field, $definition['props']['required'] ?? []),
'#title' => $settings['title'],
'#type' => $fapi_map[$prop_type],
];
In 1.2 the entire SDC Display interface doesn't work. The error here is:
TypeError: Drupal\sdc_styleguide\SDCStyleguideStoryPropertyTypePluginManager::callPluginMethodByHandledType(): Argument #1 ($type) must be of type string, array given, called in /var/www/html/docroot/modules/contrib/sdc_styleguide/src/SDCStyleguideStoryPropertyTypePluginManager.php on line 166 in Drupal\sdc_styleguide\SDCStyleguideStoryPropertyTypePluginManager->callPluginMethodByHandledType() (line 75 of modules/contrib/sdc_styleguide/src/SDCStyleguideStoryPropertyTypePluginManager.php).
This is more complicated and beyond my PHP skills :)
Active
1.2
Code