phalcon 形式的实体编号格式 volt
entity number formating in phalcon form volt
问题:
我想呈现带有格式值的表单文本。
案例
[input:text] // this is text input
[5000] // this is my text input without number_format()
[5.000] // this is my goals
代码:
$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);
您应该修改实体。如果实体可用,字段值将被覆盖。
执行以下操作:
$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
]);
其他选择是在您的模型中使用 getters/setters 以始终以所需格式输出数据。
问题:
我想呈现带有格式值的表单文本。
案例
[input:text] // this is text input
[5000] // this is my text input without
number_format()
[5.000] // this is my goals
代码:
$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);
您应该修改实体。如果实体可用,字段值将被覆盖。
执行以下操作:
$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
]);
其他选择是在您的模型中使用 getters/setters 以始终以所需格式输出数据。