Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the possibility to load multiple default field values as JSON #20168

Merged
merged 1 commit into from
Jul 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update FormField.php
  • Loading branch information
eshiol authored Apr 14, 2018
commit 421fa336242e42bf66b9cfc5af285f6c117cdaeb
9 changes: 8 additions & 1 deletion libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,14 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
$this->default = isset($element['value']) ? (string) $element['value'] : $this->default;

// Set the field default value.
$this->value = $value;
if ($element['multiple'] && is_string($value) && is_array(json_decode($value, true)))
{
$this->value = (array) json_decode($value);
}
else
{
$this->value = $value;
}

foreach ($attributes as $attributeName)
{
Expand Down