mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-26 03:38:47 +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']) {
|
||||
$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)
|
||||
{
|
||||
$forms = iterator_to_array($forms);
|
||||
|
||||
if ($viewData === null) {
|
||||
if (isset($forms['prefix'])) {
|
||||
$forms['prefix']->setData(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$data = $this->si_formatter->convertValue($viewData);
|
||||
|
||||
$forms = iterator_to_array($forms);
|
||||
|
||||
if (isset($forms['prefix'])) {
|
||||
$forms['value']->setData($data["value"]);
|
||||
$forms['prefix']->setData($data['prefix_magnitude']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue