mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 19:58:53 +02:00
If no data is set, the SIUnitType uses no prefix now.
This commit is contained in:
parent
5cc08af7b6
commit
d32ced7547
1 changed files with 7 additions and 3 deletions
|
@ -117,7 +117,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
|
|
||||||
if ($options['show_prefix']) {
|
if ($options['show_prefix']) {
|
||||||
$builder->add('prefix', ChoiceType::class, [
|
$builder->add('prefix', ChoiceType::class, [
|
||||||
'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3 ]
|
'choices' => ['M' => 6, 'k' => 3, '' => 0, 'm' => -3, 'µ' => -6 ]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +143,18 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
||||||
*/
|
*/
|
||||||
public function mapDataToForms($viewData, $forms)
|
public function mapDataToForms($viewData, $forms)
|
||||||
{
|
{
|
||||||
|
$forms = iterator_to_array($forms);
|
||||||
|
|
||||||
if ($viewData === null) {
|
if ($viewData === null) {
|
||||||
|
if (isset($forms['prefix'])) {
|
||||||
|
$forms['prefix']->setData(0);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->si_formatter->convertValue($viewData);
|
$data = $this->si_formatter->convertValue($viewData);
|
||||||
|
|
||||||
$forms = iterator_to_array($forms);
|
|
||||||
|
|
||||||
if (isset($forms['prefix'])) {
|
if (isset($forms['prefix'])) {
|
||||||
$forms['value']->setData($data["value"]);
|
$forms['value']->setData($data["value"]);
|
||||||
$forms['prefix']->setData($data['prefix_magnitude']);
|
$forms['prefix']->setData($data['prefix_magnitude']);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue