I am trying to create a form where the names of the inputs are an array. I am going through an array sent from another view to get fields to show. in this example I want to show 3 fields.
$someResult = array('0','1','2');
$fields = array(0=>'fName',1=>'mName',2=>'lName');
@foreach($someResult as $k){
<td> {!! Form::text($fields[$k][],$someVal) !!}</td>
@endforeach
I tried simplifing it to straight php:
foreach ($someResult as $k){
echo "<tr><td><input type='text' name='".$fields[$k][]."' value='".$someVal."'></tD></tr>";
}
Either way, i get the error "Cannot use [] for reading"
How can i declare name argument as an array?
My goal is something like:
<td>
<input type='text' name='fName[]' value='someVal'>
</td>
<td>
<input type='text' name='mName[]' value='someVal'>
</td>
//etc.....
Form::text($fields[$k][],$someVal)specifically$fields[$k][]That last[]should be part of the name array$fields = array(0=>'fName[]',1=>'mName[]',2=>'lName[]');etc. Or as part of the "string" name, you could concatenate it etc... later of courseForm::text($fields[$k].'[]',$someVal)