mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-28 12:40:08 +02:00
Force that an currency has an iso currency code
Otherwise it will crash a lot of formatter code (and a currency which is not existing is not really useful)
This commit is contained in:
parent
059110ae7a
commit
2d5f23271f
2 changed files with 4 additions and 3 deletions
|
@ -62,6 +62,7 @@ class Currency extends AbstractStructuralDBElement
|
||||||
* @var string the 3-letter ISO code of the currency
|
* @var string the 3-letter ISO code of the currency
|
||||||
*/
|
*/
|
||||||
#[Assert\Currency]
|
#[Assert\Currency]
|
||||||
|
#[Assert\NotBlank]
|
||||||
#[Groups(['extended', 'full', 'import'])]
|
#[Groups(['extended', 'full', 'import'])]
|
||||||
#[ORM\Column(type: Types::STRING)]
|
#[ORM\Column(type: Types::STRING)]
|
||||||
protected string $iso_code = "";
|
protected string $iso_code = "";
|
||||||
|
@ -113,12 +114,12 @@ class Currency extends AbstractStructuralDBElement
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIsoCode(): ?string
|
public function getIsoCode(): string
|
||||||
{
|
{
|
||||||
return $this->iso_code;
|
return $this->iso_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIsoCode(?string $iso_code): self
|
public function setIsoCode(string $iso_code): self
|
||||||
{
|
{
|
||||||
$this->iso_code = $iso_code;
|
$this->iso_code = $iso_code;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
||||||
$is_new = null === $entity->getID();
|
$is_new = null === $entity->getID();
|
||||||
|
|
||||||
$builder->add('iso_code', CurrencyType::class, [
|
$builder->add('iso_code', CurrencyType::class, [
|
||||||
'required' => false,
|
'required' => true,
|
||||||
'label' => 'currency.edit.iso_code',
|
'label' => 'currency.edit.iso_code',
|
||||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue