Open iamalessiopaoletti opened 1 year ago
Hi,
I tried to build a gutenberg block with a complex field but I don't understand how to display the values, the method that I use usually in container fields doesn't work:
` Block::make( __( 'F.A.Q.' )) ->add_fields( array(
Field::make( 'complex', 'faq', __( 'FAQ' )) ->add_fields( array( Field::make( 'text', 'title', __( 'Titolo' )), Field::make( 'rich_text', 'txt', __( 'Testo' ) ), Field::make( 'image', 'image', __( 'Block Image' )), Field::make( 'file', 'file', __( 'File download' )), )) ->set_header_template('<%- title %>') ->set_collapsed(true), )) ->set_render_callback( function ( $fields, $attributes, $inner_blocks ) { ?> <div class="faq"> <?php $fields_faq = carbon_get_the_post_meta('faq'); if($fields_faq){ foreach ( $fields_faq as $f ){ ?> <h2><?php echo $f['title']; ?></h2> <?php }} ?> </div> <?php });
`
I reproduced it. As I see in $fields_faq = null. In the callback function $fields is available as an array.
Hi,
I tried to build a gutenberg block with a complex field but I don't understand how to display the values, the method that I use usually in container fields doesn't work:
` Block::make( __( 'F.A.Q.' )) ->add_fields( array(
`