Skip to content

Commit

Permalink
Fix Matrix > Super Table > Matrix field settings not saving correctly…
Browse files Browse the repository at this point in the history
…, due to lack of project config change detection
  • Loading branch information
engram-design committed Oct 8, 2022
1 parent e43f692 commit f00392d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fields/SuperTableField.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,9 @@ public function setBlockTypes(array|SuperTableBlockType $blockTypes): void
}
}

// Add a random value to trigger project config changes, we still need to figure out
$blockType->changedFieldIndicator = rand();

$fieldLayoutTab->setElements($layoutElements);
$this->_blockTypes[] = $blockType;
}
Expand Down
6 changes: 6 additions & 0 deletions src/models/SuperTableBlockType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class SuperTableBlockType extends Model implements GqlInlineFragmentInterface
*/
public ?string $uid = null;

// Required for some reason to prompt project config that a change has occured when modifying fields
// for Matrix > ST > Matrix. Changes won't apply unless something in the blocktype model has changed,
// so for the moment, we'll use this as a flag to always trigger a save, until we figure it out.
public mixed $changedFieldIndicator = null;


// Public Methods
// =========================================================================
Expand Down Expand Up @@ -138,6 +143,7 @@ public function getConfig(): array
$field = $this->getField();

$config = [
'changedFieldIndicator' => $this->changedFieldIndicator,
'field' => $field->uid,
'fields' => [],
];
Expand Down

0 comments on commit f00392d

Please sign in to comment.