Skip to content

Commit

Permalink
Merge pull request #208 from ttempleton/fix-label-issue
Browse files Browse the repository at this point in the history
Ensure field layout IDs are set when setting a field's block types - Thanks @ttempleton
  • Loading branch information
pvldigital authored Apr 24, 2019
2 parents 69abff3 + cca124d commit a2b24b4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,19 @@ public function setBlockTypes($blockTypes)

$fieldLayout = Craft::$app->getFields()->assembleLayout($fieldLayoutPost, $requiredFieldPost);
$fieldLayout->type = Block::class;

// Ensure the field layout ID is set, if it exists
$layoutIdResult = (new Query)
->select(['fieldLayoutId'])
->from('{{%neoblocktypes}}')
->where(['id' => $blockTypeId])
->one();

if ($layoutIdResult !== null)
{
$fieldLayout->id = $layoutIdResult['fieldLayoutId'];
}

$newBlockType->setFieldLayout($fieldLayout);
}
}
Expand Down

0 comments on commit a2b24b4

Please sign in to comment.