为什么在代码中使用laravel集体打印“

时间:2019-05-10 08:40:33

标签: laravel laravel-5 laravelcollective

我想生成html属性,例如data-inputmask ='“ mask”:“(999)999-9999”',但是loravel集体打印data-inputmask =“'mask':'(999)999-9999' ”,然后使用“&#0 3 9”。为什么?

    {!! Form::text('mobile', null, ['class' => 'form-control text-left', 'data-inputmask' => '"mask": "(999) 999-9999"', 'data-mask']) !!}

laravel collective output: 

<input class="form-control text-left" data-inputmask="&#039;mask&#039;: &#039;(999) 999-9999&#039;" data-mask name="phone" type="text" id="phone">

但是我想要

<input class="form-control text-left" data-inputmask="'mask': '(999) 999-9999'" data-mask name="phone" type="text" id="phone">

1 个答案:

答案 0 :(得分:0)

这些是escape characters.

尝试将您的单引号替换为data-inputmask的双引号:

{!! Form::text('mobile', null, ['class' => 'form-control text-left', 'data-inputmask' => "'mask': '(999) 999-9999'", 'data-mask']) !!}

有关single quoted strings的更多信息。