AdvancedCustomFields / AdvancedCustomFields/acf

[Feature request/Bug fix] InnerBlocks template doesn't update

Open
#364 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

Hey guys,

Loving the new release so far, although I am having an issue with the InnerBlocks template not updating.

Please see example;

Inside my block template

<?php 
$columns = get_field('number_of_columns');
$align = get_field('align');
$template = array();

for($i = 0; $columns > $i; $i++):
    array_push($template,  array( 'core/column', array(), array()));
endfor;

?>

<div class="row row__<?=$align?>">
    <h3>Columns Block</h3>
    <InnerBlocks template="<?= esc_attr( wp_json_encode( $template ) ) ?>" templateLock="all" />
</div>

I have a range field which lets you set a number between 1 and 12 (the number of columns). I am then using a for loop to build the InnerBlocks template. This does work however, the changes are 'live'. It requires the user to refresh the page. I'm assuming this is something to so do with React not compiling properly.

Is there an easy fix for this or is this not possible? From my side this would be very useful since we are building a custom Columns / Column block for our theme.

As you can see below it does work, although you have to update the post and refresh the page to update the template.

Screenshot 2020-08-20 at 13 42 25

Screenshot 2020-08-20 at 13 42 02

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the InnerBlocks template example in the issue and reproduce the behavior in the WordPress editor using the PHP loop and range field. Verify whether changing the column count updates the template without saving and refreshing the post. Done means the template reflects the changed value live, or the issue documents a confirmed platform limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.