0

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

Dewa Dwi
  • 105
  • 2
  • 9

1 Answers1

0

I think this is what you need:

{{{ Form::number('amount', 'Rp.' . number_format($cash->amount, 2), array('class'=>'form-control')) }}}
Tra Lee
  • 113
  • 1
  • 8
  • aw, taht's not error, but the value not showing. in console i see the warning ``The specified value "1,000,000.00" cannot be parsed, or is out of range.`` – Dewa Dwi May 27 '21 at 01:27
  • Firstly, can you remove the `'Rp.' .` from the code above and try again. I forgot this is a number input type. – Tra Lee May 27 '21 at 01:40
  • I already delete the Rp. , but same error. – Dewa Dwi May 27 '21 at 04:19