Php Elementor Extension:如何将repeater项标题设置为select的当前值

Php Elementor Extension:如何将repeater项标题设置为select的当前值,php,wordpress,elementor,Php,Wordpress,Elementor,我目前正在开发elementor扩展,我有以下问题:我想将repeater项的标题设置为select的当前值。如果我的select控件标题为'country',并且我使用{{{{country}}lateron,我只得到1,2,3,4,5 我在elementor文档中找不到关于此的任何信息 require_once(plugin_dir_path(__FILE__).'countries.php'); $this->start_controls_sect

我目前正在开发elementor扩展,我有以下问题:我想将repeater项的标题设置为select的当前值。如果我的select控件标题为'country',并且我使用
{{{{country}}
lateron,我只得到1,2,3,4,5

我在elementor文档中找不到关于此的任何信息


        require_once(plugin_dir_path(__FILE__).'countries.php');

        $this->start_controls_section(
            'content_section',
            [
                'label' => __( 'Content', 'plugin-name' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
            ]
        );

        $repeater = new \Elementor\Repeater();

        $repeater->add_control(
            'country',
            [
                'label' => __('Country Name', 'elementor-cc-details'),
                'type' => \Elementor\Controls_Manager::SELECT,
                'default' => '',
                'options' => $countries,
                'label_block' => true
            ]
        );


        $repeater->add_control(
            'list_content', [
                'label' => __( 'Content', 'plugin-domain' ),
                'type' => \Elementor\Controls_Manager::WYSIWYG,
                'default' => __( 'List Content' , 'plugin-domain' ),
                'show_label' => false,
            ]
        );



        $this->add_control(
            'list',
            [
                'label' => __( 'Repeater List', 'plugin-domain' ),
                'type' => \Elementor\Controls_Manager::REPEATER,
                'fields' => $repeater->get_controls(),
                'default' => [

                ],
                'title_field' => '{{{ country}}}',
            ]
        );

        $this->end_controls_section();

    }

预期的结果是,如果我在
中选择一个值,则repeater项将其值作为name。可能是它的
{{{country.select}}
什么的。我没有发现。

我通过一个变通办法解决了我的问题。真正的问题尚未解决,因为您无法在键和值之间进行选择

暂时的解决方案是像这样使用countries数组

$countries = [
"Afghanistan" => "Afghanistan",
"Albania" => "Albania",
"Algeria" => "Algeria",
"Andorra" => "Andorra",
"Angola" => "Angola",
...

因为{{country}}}变量自动使用数组键(如果不存在1,2,3,4,5)。

。真正的问题尚未解决,因为您无法在键和值之间进行选择

暂时的解决方案是像这样使用countries数组

$countries = [
"Afghanistan" => "Afghanistan",
"Albania" => "Albania",
"Algeria" => "Algeria",
"Andorra" => "Andorra",
"Angola" => "Angola",
...
因为{{country}}}变量会自动使用数组键(如果不存在1,2,3,4,5)