WordPress / Gravity Forms:使用文本字段时出错并用税填充它

时间:2015-07-19 18:34:35

标签: php wordpress custom-post-type taxonomy gravity-forms-plugin

我使用以下插件让用户使用Gravity Forms发布他们的内容:https://wordpress.org/support/plugin/gravity-forms-custom-post-types

当我使用文本字段并希望在其中保存分类时,我收到以下错误(前端和后端):

Fatal error: Cannot use string offset as an array in ..../gravity-forms-custom-post-types/gfcptaddonbase.php on line 301

知道为什么吗?

这是导致问题的功能:

function setup_taxonomy_field( &$field, $taxonomy ) {

        $first_choice = $field['choices'][0]['text'];
        $field['choices'] = $this->load_taxonomy_choices( $taxonomy, $field['type'], $first_choice );

        //now check if we are dealing with a checkbox list and do some extra magic
        if ( $field['type'] == 'checkbox' ) {
            //clear the inputs first
            $field['inputs'] = array();

            $counter = 0;
            //recreate the inputs so they are captured correctly on form submission
            foreach( $field['choices'] as $choice ) {
                $counter++;
                if ( ($counter % 10) == 0 ) $counter++; //thanks to Peter Schuster for the help on this fix
                $id = floatval( $field['id'] . '.' . $counter );
                $field['inputs'][] = array('label' => $choice['text'], 'id' => $id);
            }
        }
    }

如果我注释掉函数的第一行,它就不会再出现错误,并且无论如何都会提交标记。但我需要这条线吗?

0 个答案:

没有答案