简体   繁体   中英

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

My blade.php code is:

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

HtmlBuilder.php code is

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

The error message is:

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)

And i have changed the blade.php as like

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

and

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

and also text('text', .. But nothing works for me and throwing me the same error as i mentioned above.. I have gone through all the similar questions related to this but none of those answers solved my problem . So please avoid doing duplication of this question and give me clear and correct solution..

You are adding tactic[] to the name which is an array and hence when you post the data it is going as an array. Either remove it or at php end use implode .

If you want to take the input as an array then you can use this code

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM