Problem :
I want to render form text with formatting value.
Case
[input:text] // this is text input
[5000] // this is my text input without
number_format()
[5.000] // this is my goals
Code :
$protQty = new Text('protQty',[
'placeholder' => 'Jumlah Pesan ( Hanya Angka ) ',
'class' => 'form-control ',
'value' => number_format($entity->protQty,0,",","."), //unworking code
'readonly' => true
]);
$protQty->setLabel('Jumlah Permintaan');
$this->add($protQty);
You should modify the entity. Field value is overwritten if entity is available.
Do the following:
$entity->protQty = number_format($entity->protQty, 0, ",", ".");
$protQty = new Text('protQty',[
'placeholder' => 'Jumlah Pesan ( Hanya Angka ) ',
'class' => 'form-control ',
// Not needed anymore
// 'value' => number_format($entity->protQty,0,",","."), //unworking code
'readonly' => true
]);
Other option would be to use getters/setters in your model to always output the data in the desired format.