0
votes

I'll try to be short: Multilingual Wordpress site with custom post type registered in functions.php and CMB2 for creating custom forms. The plugin for multilingual is q-translate-x and also using CMB2-qTranslate.

My problem is that I'm losing all line breaks and all <p> tags when I switch the language but it only fails if the editor is contained in a repeatable group. If I add the wysiwyg edit as normal field It works fine.

-Relevant code for the normal field (this works fine):

$cmb_tb->add_field( array(
    'name'    => esc_html__( 'Historia', 'cmb2' ),
    'desc'    => esc_html__( 'field description (optional)', 'cmb2' ),
    'id'      => $prefix . 'historia',
    'type'    => 'wysiwyg',
    'options' => array( 'textarea_rows' => 5, 'editor_class' => 'cmb2-qtranslate'),
) );

-Relevant code for repeatable field (this loses line breaks and <p> tags on language switching):

<pre><code>
$group_field_id = $cmb_tb->add_field( array(
'id'          => 'Fincas',
'type'        => 'group',
'description' => __( 'Fincas', 'cmb2' ),
// 'repeatable'  => false, // use false if you want non-repeatable group
'options'     => array(
    'group_title'   => __( 'Finca {#}', 'cmb2' ), // since version 1.1.4, {#} gets replaced by row number
    'add_button'    => __( 'AƱadir otra Finca', 'cmb2' ),
    'remove_button' => __( 'Eliminar Finca', 'cmb2' ),
 //   'sortable'      => true, // beta
    'closed'     => false, // true to have the groups closed by default
),
) );

$cmb_tb->add_group_field($group_field_id, array(
    'name'    => esc_html__( 'Nombre Finca', 'cmb2' ),
    'desc'    => esc_html__( '', 'cmb2' ),
    'id'      => $prefix . 'nombre_finca',
    'type'    => 'wysiwyg',
    'options' => array( 'textarea_rows' => 5, 'editor_class' => 'cmb2-qtranslate')
) );

</code></pre>

This is driving me crazy. I've created a sample website with this problem for testing. I can give access to anyone who feels that can help.

Many thanks in advance.

1
is $prefix different for different fields? - Banzay
$prefix is the id for the post type name. In the runtime I see one case id="Fincas_0_tb_parque_natural_nombre_finca". Thanks. - user740155

1 Answers

0
votes

Finally, I figured out. It was as easy to add 'wpautop' => false to options array