Cast to array in setValue() instead

This commit is contained in:
Bob den Otter
2019-03-11 14:45:50 +01:00
parent c2c3981029
commit f2011aee74
6 changed files with 11 additions and 8 deletions
-1
View File
@@ -32,7 +32,6 @@
Escaped: <br>
<div class="box text_markup_c">{{ record.text_markup|e }}</div><br>
</p>
<hr>
@@ -235,7 +235,7 @@ class ContentEditController extends TwigAwareController
$value = Json::findArray($value);
}
$field->setValue((array) $value);
$field->setValue($value);
}
private function updateTaxonomy(Content $content, string $key, $taxonomy): void
+1 -1
View File
@@ -84,7 +84,7 @@ class ContentFixtures extends Fixture implements DependentFixtureInterface
$field->setName($name);
if (isset($preset[$name])) {
$field->setValue((array) $preset[$name]);
$field->setValue($preset[$name]);
} else {
$field->setValue($this->getValuesforFieldType($name, $fieldType));
}
+2 -2
View File
@@ -198,9 +198,9 @@ class Field implements Translatable
return $value;
}
public function setValue(array $value): self
public function setValue($value): self
{
$this->value = $value;
$this->value = (array) $value;
return $this;
}
+2 -1
View File
@@ -16,7 +16,8 @@ class MarkdownField extends Field implements Excerptable
public function __toString(): string
{
$markdown = new Markdown();
$value = $this->getValue();
return $markdown->toHtml(implode(', ', $this->getValue()));
return $markdown->toHtml(reset($value));
}
}
+5 -2
View File
@@ -14,9 +14,12 @@ use Tightenco\Collect\Support\Collection;
*/
class SlugField extends Field
{
public function setValue(array $value): parent
public function setValue($value): parent
{
$value = Str::slug(reset($value));
if (is_array($value)) {
$value = reset($value);
}
$value = Str::slug($value);
$this->value = [$value];
return $this;