Drupal 7自定义表单在php 7.2中无法使用字符串偏移作为数组错误

问题描述 投票:0回答:1

我有一个自定义的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的数组

有人可以帮忙吗?预先感谢。

php drupal-7 php-7.2
1个回答
0
投票

您必须先声明空数组,然后再分配它

 $form = array();

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

$form['general_details']['salutation'] = array(
         '#type' => 'select',....
© www.soinside.com 2019 - 2024. All rights reserved.