簡體   English   中英

Laravel-htmlentities()期望參數1為字符串,給定數組

[英]Laravel - htmlentities() expects parameter 1 to be string, array given

我的blade.php代碼是:

{!! Form::input('text', 'tactic[]', null, array('id' => 'tactic', 'class' => ' form-control TabOnEnter', 'placeholder' => 'Tactics_1')) !!}

HtmlBuilder.php代碼是

public function escapeAll($value)
{
    return htmlentities($value, ENT_QUOTES, 'UTF-8');
}

錯誤消息是:

ErrorException in HtmlBuilder.php line 65:
htmlentities() expects parameter 1 to be string, array given (View: /home/seyali-02/dev/htdocs/scam/resources/views/dashboard/Scam/edit.blade.php)

而且我已經將blade.php更改為

{!! Form::input('text','', 'tactic[]', null, array('id' => 'tactic', 'class' => ' form-control TabOnEnter', 'placeholder' => 'Tactics_1')) !!}

{!! Form::text('name', 'tactic[]', null, array('id' => 'tactic', 'class' => ' form-control TabOnEnter', 'placeholder' => 'Tactics_1')) !!}

還有text('text', ..但是,沒有什么對我有用,並且拋出了與我上面提到的相同的錯誤。.我經歷了與此相關的所有類似問題,但是這些答案都不能解決我的問題,因此請避免重復這個問題,並給我清楚正確的解決方案。

您將tactic[]添加到數組名稱,因此,當您發布數據時,它將作為數組。 要么將其刪除,要么在php末尾使用implode

如果要將輸入作為數組,則可以使用此代碼

{! Form :: text('tactic []',null,['id'=>'tactic','class'=>'form-control TabOnEnter','placeholder'=>'Tactics_1'])!!}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM