How to use Laravel Directive Currency format in Blade with laravel Collective

834 Views Asked by At

I have some textbox like this {{{ Form::number('amount', $cash->amount , array('class'=>'form-control')) }}} but I want to display the textbox in currency formatting

I have try to make Laravel directive like this Blade::directive('convert', function ($money) { return "<?php echo 'Rp.' . number_format($money, 2); ?>"; });

and when I try in textbox {{{ Form::number('amount', @convert($cash->amount) , array('class'=>'form-control')) }}} that return parse error unexpected '<' and the I'm trying to call the convert in label but that's error too. and when I'm not using variabel, just doing like this <label>@convert(11223344)</label> that's work.

Thankyou

1

There are 1 best solutions below

3
Tra Lee On

I think this is what you need:

{{{ Form::number('amount', 'Rp.' . number_format($cash->amount, 2), array('class'=>'form-control')) }}}