0

I'm working with symfony5 and easyadmin3. There is no error displayed. Here is the trouble :

I got a method get() in my entity

'''
    /**
    * @ORM\Column(type="integer")
     */
    private $montageCharge;
////
  public function getMontageCharge(): ?int
    {
      var_dump((($this->montageCharge)/100));
        return (($this->montageCharge)/100);
    }
public function setWorkCharge(int $workCharge): self
    {
        $this->workCharge = $workCharge;

        return $this;
    }
'''

Which i'm using to get numbers with coma. The dump confirm it with a number with coma and a float format :

Product.php:159:int 4
Product.php:159:float 0.7

However, i didnt manage to see it in my crud controller, where they only appear as a rounded number, no coma. here is the configureField in my controller :

'''
NumberField::new('Work_Charge'),
''' 

The crudcontroller is showing 1 instead of 0.7. So my question is : how can i manage to diffuse correct number with coma, using easyadmin3 crudcontroller?

I tried a lot of other field so far, no one made it.

Cephalopodius
  • 117
  • 1
  • 10
  • Try to use MoneyField instead of NuberField – Flash May 26 '21 at 14:11
  • 1
    Sure it work with moneyfield, but the currency's symbol is kind of annoying there :/ . And it doesnt work with 3 numbers post coma, wich i will encounter at some point on my current project... – Cephalopodius May 26 '21 at 15:30
  • You are returning `int` from get function, just change it to `public function getMontageCharge(): ?float` and it will return what you want. – Flash May 26 '21 at 16:18
  • It worked ! Nice, thank for your help ! The dump returning a float value prevented me to think about that ;). Have a nice day ! – Cephalopodius May 27 '21 at 06:31

0 Answers0