Search code examples
laravellaravel-bladehtml-escape-characterslaravelcollective

Laravel Blade Form::select -- now forcing escape?


I've had this code running since L5.0. With the latest update to L5.3.30 + the dependencies, it appears to be broken. Perhaps I've done something wrong since the beginning?

Here is the simplified code:

    {!! Form::select('currency', ['USD'=>'USD: *escape code here*'], 
        null, ['class'=>'form-control', "required", 'id'=>'currency']) !!}

For the last few years this code has returned a select box with text like this: "USD: $"

After composer update to L5.3.30, on all servers (test, dev, prod), it now returns the html symbol instead: "USD: escape code here"

I have temporarily (and successfully) patched this using:

 <select name = 'currency' id="currency" required class="form-control">
       @foreach (\Helper::currency() as $k=>$v)
                  <option  value="{{$k}}">{!! $v !!}</option>
       @endforeach
 </select>

The above code has the escape code for the currency in the $v var, and shows up correctly in the select box.

Please help - this breaks quite a few forms on my app.

Thank you.

EDIT: I can still correctly display unescaped text using {!! !!} everywhere else. It appears to only affect Form::select() items. I therefore am starting to think this is not an issue with Laravel's blade escape, but rather with the latest version of the Laravel Collective Form function

SOLUTION: I noted this to the Laravel Collective Dev team, but this has apparently NOT been rolled back. See https://github.com/LaravelCollective/html/issues/296 for latest.


Solution

  • You can "fix" it by downgrading Laravelcollective html package to version 5.3.0 (down from 5.3.1 which is current version). Just edit composer.json "require"

    "laravelcollective/html": "5.3.*",
    

    with this:

    "laravelcollective/html": "5.3.0",
    

    Downside is that you will use older version which may have some other issues which was already fixed in 5.3.1, but i dont have any specific information on that.