Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htmlspecialchars() expects parameter 1 to be string array given

I have an input field in which I am passing an array from my controller as hidden input but its giving me this error of array given.

Code of my view is

    <input type="hidden" name="DiseaseDiagnosed[]" value="{{$DiseaseDiagnosed}}">

Code of controller passing the value to view is

 return view('/doctorPanel/diagnoseDisease', ['chart' => $chart, 'patient' => $patient, 'symptomsStated' => $symptomsStated, 'DiseaseDiagnosed' => $DiseaseDiagnosed]);

Kindly tell me why I am getting this error

like image 576
Nida Akram Avatar asked Oct 18 '25 14:10

Nida Akram


1 Answers

<input type="hidden" name="DiseaseDiagnosed[]" value="{!! jsond_encode($DiseaseDiagnosed) !!}">

Actually, your input is DiseaseDiagnosed is an array which is returned to view.

So you have to use {{ json_decode($DiseaseDiagnosed) }}

You can also try

@foreach($DiseaseDiagnosed as $disease)

  <input type="hidden" name="DiseaseDiagnosed[]" value="{{ $disease }}">

@endforeach
like image 131
Romantic Dev Avatar answered Oct 21 '25 03:10

Romantic Dev