Drupal 7自定义表单无法在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的数组

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

xiaoheige2008 回答:Drupal 7自定义表单无法在php 7.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',....
本文链接:https://www.f2er.com/2971613.html

大家都在问