#wrapper_attributes implementation

Created on 14 December 2023, 7 months ago
Updated 10 January 2024, 6 months ago

Using the form API to generate a chart, it seems that in my case, the #wrapper_attributes is not considered.
I am doing something wrong ?

My chart element

    $chart = [
      '#type' => 'chart',
      '#chart_type' => 'column',
    ];
    $chart['series'] = [
      '#type' => 'chart_data',
      '#title' => t('Invesment'),
      '#data' => $chartData['data'],
    ];
    $chart['xaxis'] = [
      '#type' => 'chart_xaxis',
      '#title' => t('Years'),
      '#labels' => $chartData['labels'],
    ];
    $chart['#legend_position'] = 'none';
    $chart['#wrapper_attribute'] =  [
                                ['id'] =>'test-id',
                                ['class'] =>'test-class',
                                ['custom-attribute'] =>'test-custom-attribute',
                              ];
   
πŸ’¬ Support request
Status

Closed: works as designed

Version

5.0

Component

Chart API

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @superlolo95
  • πŸ‡ΊπŸ‡ΈUnited States andileco

    Can you double-check it's not supposed to be $chart['#wrapper_attributes'] (including an s at the end)?

    1. you are right my code is wrong
       $chart['#wrapper_attributes'] =  [
                                    'id' =>'test-id',
                                    'class'] =>'test-class',
                                    ['custom-attribute'] =>'test-custom-attribute',
                                  ];

    But it seems that this is not working for other types of elements.
    I am using them in a webform. So maybe it is related to webform.

  • Status changed to Closed: works as designed 6 months ago
  • πŸ‡ΊπŸ‡ΈUnited States andileco
Production build 0.69.0 2024