簡體   English   中英

Drupal 7 自定義表單無法使用字符串偏移量作為 php 7.2 的數組錯誤

[英]Drupal 7 custom form Cannot use string offset as an array error with php 7.2

我有一個自定義的 drupal 7 表單,如下所示

   $form['general_details'] = array(
         '#type' => 'fieldset',
         '#title' => t('General'),
         '#description' => t('General Information.'),
         '#required' => TRUE,
         );

   $form['general_details']['salutation'] = array(
         '#type' => 'select',....

我在“$form['general_details']['salutation']”行中出現錯誤錯誤:無法使用字符串偏移量作為 PHP7.2 的數組

有人可以幫忙嗎? 提前致謝。

您必須在分配之前聲明空數組

 $form = array();

$form['general_details'] = array(
         '#type' => 'fieldset',
         '#title' => t('General'),
         '#description' => t('General Information.'),
         '#required' => TRUE,
);

$form['general_details']['salutation'] = array(
         '#type' => 'select',....

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM