Но когда я использую только один повторитель, тогда встроенное редактирование и сохранение отлично работают.
Теперь я использовал этот add_inline_editing_attributes для встроенного редактирования. Итак, что мне делать, чтобы сохранить встроенный текст редактирования для двух повторителей?
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Test Plugin', 'test-plugin-td' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$repeater->add_control(
'text',
[
'label' => __( 'Business Hour', 'test-plugin-td' ),
'type' => \Elementor\Controls_Manager::TEXT,
'label_block' => true,
'placeholder' => __( 'First Name', 'test-plugin-td' ),
'default' => __( 'First Name', 'test-plugin-td' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'business_hours',
[
'label' => __( 'Test Plugin', 'test-plugin-td' ),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'text' => __( 'First Name', 'test-plugin-td' ),
],
[
'text' => __( 'Last Name', 'test-plugin-td' ),
],
],
'title_field' => '{{{ text }}}',
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_2section',
[
'label' => esc_html__( 'Test Plugin', 'test-plugin-td' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$repeskeater = new Repeater();
$repeskeater->add_control(
'text2',
[
'label' => __( 'Business Hour', 'test-plugin-td' ),
'type' => \Elementor\Controls_Manager::TEXT,
'label_block' => true,
'placeholder' => __( 'First Name', 'test-plugin-td' ),
'default' => __( 'First Name', 'test-plugin-td' ),
'dynamic' => [
'active' => true,
],
]
);
$this->add_control(
'business_2hours',
[
'label' => __( 'Test Plugin', 'test-plugin-td' ),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeskeater->get_controls(),
'default' => [
[
'text' => __( 'First Name', 'test-plugin-td' ),
],
[
'text' => __( 'Last Name', 'test-plugin-td' ),
],
],
'title_field' => '{{{ text2 }}}',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
echo '
- ';
foreach ( $settings['business_hours'] as $index => $item ) :
$text_key = $this->get_repeater_setting_key( 'text', 'business_hours', $index );
$this->add_inline_editing_attributes( $text_key );
?> - >
-
>
Подробнее здесь: https://stackoverflow.com/questions/792 ... e-repeater
Мобильная версия