Number format in laravel

0

How can I do the php numberformat in laravel for a text type input two decimals?

{!!Form::text(number_format(campoaformatear,2,'.',',')null,['class'=>'form-control'])!!}
    
asked by Santiago Muñoz 01.08.2016 в 16:15
source

2 answers

1

I think you should check with a shorthand of if / else, if there is $ field, to avoid an error when trying to format a null

{!! Form::text(
($campo) ? number_format($campo, 2, '.', ',') : ''
, null, ['class'=>'form-control']) !!}
    
answered by 27.08.2016 в 17:56
0

The syntax you use should work without problem, although you need a comma (,), however I do not think you want to assign a name to the field that includes two decimals.

{!! Form::text(number_format($campo, 2, '.', ','), null, ['class'=>'form-control']) !!}
    
answered by 01.08.2016 в 16:24