Skip to content

Commit a2bba83

Browse files
author
Daniel Fariña Hernández
committedOct 19, 2017
Allow to unset fields
1 parent 19e38fc commit a2bba83

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed
 

‎src/AutopilotContact.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,6 @@ public function toRequest($prependKey = true)
200200

201201
/** @var AutopilotField $field */
202202
foreach($this->fields as $field) {
203-
//TODO: how do you "unset" fields with Autopilot? Their API doesn't say anything about it
204-
if ($field->getValue() === null) {
205-
continue;
206-
}
207-
208203
if (! $field->isReserved()) {
209204
$result['custom'][$field->formatName()] = $field->getValue();
210205
} else {
@@ -246,4 +241,4 @@ function jsonSerialize()
246241
{
247242
return $this->toArray();
248243
}
249-
}
244+
}

‎src/AutopilotField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function setValue($value)
229229
}
230230

231231
// type of field is set in the constructor
232-
if ($this->getType() !== $type) {
232+
if (($this->getType() !== $type) && !is_null($value)) {
233233
throw AutopilotException::typeMismatch($this->getType(), $type);
234234
}
235235

0 commit comments

Comments
 (0)
Please sign in to comment.