- Issue created by @lizuka
The following error appears when populating a CshsElement form element.
TypeError: Drupal\cshs\Component\CshsOption::__construct(): Argument #1 ($label) must be of type string, Drupal\cshs\Component\CshsOption given, called in /app/web/modules/contrib/cshs/src/Element/CshsElement.php on line 92 in Drupal\cshs\Component\CshsOption->__construct() (line 22 of modules/contrib/cshs/src/Component/CshsOption.php).
foreach($terms as $term){
$cshc_options[$term->id()] = new CshsOption($term->label(), $term->parent->target_id);
}
$form['term_list'] = [
'#type' => CshsElement::ID,
'#label' => 'Term list',
'#required' => TRUE,
'#label_attributes' => ['class' =>['form-required js-form-required']],
'#none_value' => null,
'#force_deepest' => true,
'#options' => $cshc_options,
];
The patch in https://www.drupal.org/project/cshs/issues/3449705#comment-15610645 🐛 CshsOption could not be converted to string when using Better Exposed Filters Needs review fixes the problem.
Active
4.0
Code