Search code examples
phplaravellaravelcollective

Laravel collective add PHP variable to input type number


I am trying to add a PHP variable to an input type number, as the maximum value allowed in this field. I am using Laravel collective.

My input syntax:

{!! Form::number('credit_amount', '0.00', ['step' => '0.01', 'min' => '0.01', 'max' => '{{ $creditBalance }}', 'class' => 'text-center form-control']) !!}

I want the $creditBalance placed against the "max" attribute of the number input. I can do this without Laravel Collective, but how to do it with LC? Thanks!


Solution

  • Blade essentially just replaces {!! and !!} with <?php echo and ?> respectively, so you can use normal PHP code:

    {!! Form::number('credit_amount', '0.00', ['min' => '0.01', 'max' => $creditBalance, 'class' => 'text-center form-control']) !!}