TypeError: Cannot access offset of type string on string in Drupal\faq_block\Element\FaqFields::processFaqFields()

Created on 19 March 2024, 3 months ago

In block on click button Add Faq Item no reaction and in watchdog

TypeError: Cannot access offset of type string on string in Drupal\faq_block\Element\FaqFields::processFaqFields()

After apply patch https://www.drupal.org/project/faq_block/issues/3300951#comment-15504017 📌 Typo in file,function name (FaqFileds.php) RTBC in
/src/Element/FaqFields.php (not /src/Element/FaqFileds.php))

    $element['question'] = [
      '#type' => 'textfield',
      '#title' => t('FAQ  Title'),
/*WTpatch: TypeError: Cannot access offset of type string on string in Drupal\faq_block\Element\FaqFileds::processFaqFileds()*/
      '#default_value' => $element['#default_value']['question'] ?? '', //'#default_value' => $element['#default_value']['question'],
/*<<<*/
      '#description' => t('Enter the FAQ heading. We can also enter the HTML tags on this field.<br><small><em>Set the title field empty or blank to delete the current FAQ item</em></small>'),
      '#prefix' => '<div class="panel"><div class="panel__content">',
      '#size' => '100'
    ];
    $element['answer'] = [
      '#id' => 'answer',
      '#type' => 'text_format',
      '#title' => t('FAQ Description'),
/*WTpatch: TypeError: Cannot access offset of type string on string in Drupal\faq_block\Element\FaqFileds::processFaqFileds()*/
      //'#default_value' => ($element['#default_value']['answer'])?$element['#default_value']['answer']['value']:'',
      '#default_value' => $element['#default_value']['answer']['value'] ?? '',
/*<<<*/
      '#format' => (isset($element['#default_value']['answer']['format']))?$element['#default_value']['answer']['format']:'basic_html',

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇱Israel Promo-IL

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

Comments & Activities

Production build 0.69.0 2024