Skip to content

Commit

Permalink
Use array_merge instead of addition operator
Browse files Browse the repository at this point in the history
Using the addition operator, like this, means _archived and _draft cannot be provided by $fields. Array merge avoids this problem by overwriting the $defaults values with those present in $fields.
  • Loading branch information
assertchris committed May 7, 2019
1 parent a37182f commit d9a74f4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Webflow/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,12 @@ public function item(string $collectionId, string $itemId)
public function createItem(string $collectionId, array $fields)
{
$defaults = [
"_archived" => false,
"_draft" => false,
"_archived" => false,
"_draft" => false,
];

return $this->post("/collections/{$collectionId}/items", [
'fields' => $defaults + $fields,
'fields' => array_merge($defaults, $fields),
]);
}

Expand Down

0 comments on commit d9a74f4

Please sign in to comment.