Skip to content

Commit

Permalink
Merge pull request netgen#43 from SofLesc/fix-ezcountry-mapping
Browse files Browse the repository at this point in the history
Fix ezcountry mapping to form
  • Loading branch information
MarioBlazek committed Sep 25, 2018
2 parents 26f6131 + 6514c5b commit b7135ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions bundle/Form/FieldTypeHandler/Country.php
Expand Up @@ -61,12 +61,10 @@ public function convertFieldValueToForm(Value $value, FieldDefinition $fieldDefi

$keys = array_keys($value->countries);

return array(
$keys[0] => $value->countries[$keys[0]],
);
return reset($keys);
}

return $value->countries;
return array_keys($value->countries);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/Form/FieldTypeHandler/CountryTest.php
Expand Up @@ -39,7 +39,7 @@ public function testConvertFieldValueToForm()

$returnedValue = $country->convertFieldValueToForm($countryValue);

$this->assertEquals($countries, $returnedValue);
$this->assertEquals(['HR'], $returnedValue);
}

public function testConvertFieldValueToFormMultipleValues()
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testConvertFieldValueToFormMultipleValues()

$returnedValue = $country->convertFieldValueToForm($countryValue, $fieldDefinition);

$this->assertEquals($selectedCountries, $returnedValue);
$this->assertEquals(['HR', 'BB'], $returnedValue);
}

public function testConvertFieldValueToFormSingleValue()
Expand Down Expand Up @@ -132,7 +132,7 @@ public function testConvertFieldValueToFormSingleValue()

$returnedValue = $country->convertFieldValueToForm($countryValue, $fieldDefinition);

$this->assertEquals($selectedCountries, $returnedValue);
$this->assertEquals('HR', $returnedValue);
}

public function testConvertFieldValueToFormWithNoneSelected()
Expand Down

0 comments on commit b7135ea

Please sign in to comment.