Maniraj Murugan
Maniraj Murugan

Reputation: 9084

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..

Upvotes: 2

Views: 183

Answers (2)

Thiwanka
Thiwanka

Reputation: 97

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']) !!}

Upvotes: 1

Kinshuk Lahiri
Kinshuk Lahiri

Reputation: 1500

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.

Upvotes: 2

Related Questions