Php 未定义索引:Prestashop Selection Helper中的id_选项错误

Php 未定义索引:Prestashop Selection Helper中的id_选项错误,php,prestashop,smarty,prestashop-1.7,Php,Prestashop,Smarty,Prestashop 1.7,我正在尝试设置一个预设模块的时区下拉列表。 我仿效了这个例子- 这是我用来获取时区列表的代码: function timezones() { $timezones = []; foreach (timezone_identifiers_list() as $timezone) { $datetime = new \DateTime('now', new DateTimeZone($timezone)); $tim

我正在尝试设置一个预设模块的时区下拉列表。 我仿效了这个例子-

这是我用来获取时区列表的代码:

function timezones() {
        $timezones = [];

        foreach (timezone_identifiers_list() as $timezone) {
            $datetime = new \DateTime('now', new DateTimeZone($timezone));
            $timezones[] = [
                'sort' => str_replace(':', '', $datetime->format('P')),
                'offset' => $datetime->format('P'),
                'name' => str_replace('_', ' ', implode(', ', explode('/', $timezone))),
                'timezone' => $timezone,
            ];
        }

        usort($timezones, function($a, $b) {
            return $a['sort'] - $b['sort'] ?: strcmp($a['name'], $b['name']);
        });

        return $timezones;
    }       
然后,我尝试按照文件中的说明执行以下操作-

        $timezoneList = timezones();    
    $options = array();
    foreach ($timezoneList as $timezone)
    {
      $options[] = array(
        "id" => $timezone['offset'],
        "name" => '(UTC '.$timezone['offset'].') '.$timezone['name'].''
      );
    }
我的结果生成了一个下拉列表,其中包含我想要的列表,但值为空,并抛出以下错误- 注意文件F:\xampp\htdocs\presta02\vendor\prestashop\smarty\sysplugins\smarty\u internal\u templatebase.php(157):eval()d代码中的第786行 [8] 未定义索引:id\u选项

我的目标是得到这样的东西-

(UTC-11:00)中途岛太平洋

目前我得到这个-


(UTC-11:00)太平洋,中途岛

如果您使用了文档中的此部分

array(
    'type' => 'select',                              // This is a <select> tag.
    'label' => $this->l('Shipping method:'),         // The <label> for this <select> tag.
    'desc' => $this->l('Choose a shipping method'),  // A help text, displayed right next to the <select> tag.
    'name' => 'shipping_method',                     // The content of the 'id' attribute of the <select> tag.
    'required' => true,                              // If set to true, this option must be set.
    'options' => array(
        'query' => $options,                           // $options contains the data itself.
        'id' => 'id_option',                           // The value of the 'id' key must be the same as the key for 'value' attribute of the <option> tag in each $options sub-array.
        'name' => 'name'                               // The value of the 'name' key must be the same as the key for the text content of the <option> tag in each $options sub-array.
    )
),
或者将您选择的定义选项键从
id\u选项
转换为
id

'options' => array(
     'query' => $options,                           // $options contains the data itself.
     'id' => 'id',                                  // The value of the 'id' key must be the same as the key for 'value' attribute of the <option> tag in each $options sub-array.
     'name' => 'name'                               // The value of the 'name' key must be the same as the key for the text content of the <option> tag in each $options sub-array.
)
“选项”=>数组(
“query”=>$options,//$options包含数据本身。
'id'=>'id',//id'键的值必须与每个$options子数组中标记的'value'属性的键相同。
'name'=>'name'//name'键的值必须与每个$options子数组中标记文本内容的键相同。
)
顺便说一句,这条评论也这么说

// The value of the 'id' key must be the same as the key for 'value' attribute of the <option> tag in each $options sub-array.
//每个$options子数组中的'id'键的值必须与标记的'value'属性的键相同。
// The value of the 'id' key must be the same as the key for 'value' attribute of the <option> tag in each $options sub-array.