在Laravel Input类中发布时,输入文件不会从表单元素插入到多维数组中

时间:2013-12-18 05:20:00

标签: laravel laravel-4

我正在做一些多文件上传。我的形式中有元素(我在这里使用刀片并删除了与设计相关的html元素)

{{ Form::open(array('route' => 'cpanel.training_schedules.upload', 'files' => true)) }}
     @foreach ($trainingSchedules as $trainingSchedule)
         <input type="file" name="data[{{ $trainingSchedule->id }}][file]">
         <input type="hidden" name="data[{{ $trainingSchedule->id }}][reference]" value="{{$trainingSchedule->Course->reference}}">
         <input type="hidden" name="data[{{ $trainingSchedule->id }}][start_date]" value="{{$trainingSchedule->start_date}}">
     @endforeach
     <input type="submit" value="upload" class="btn btn-primary">
{{ Form::close() }}

当我提交此表单时,我尝试转储Input :: all()时得到的是

array(2) [
    '_token' => string (40) "7UYMf87Nm1wLilJaQX0wLawwO1jxH56EceRRE08P"
    'data' => array(14) [
        '3' => array(2) [
            'reference' => string (5) "IE928"
            'start_date' => string (19) "2013-10-27 00:00:00"
        ]
        '4' => array(2) [
            'reference' => string (5) "FE160"
            'start_date' => string (19) "2013-12-15 00:00:00"
        ]
        '5' => array(2) [
            'reference' => string (5) "EE817"
            'start_date' => string (19) "2013-11-24 00:00:00"
        ]
        '6' => array(2) [
            'reference' => string (5) "EE817"
            'start_date' => string (19) "2013-11-24 00:00:00"
        ]
        '7' => array(2) [
            'reference' => string (5) "EE817"
            'start_date' => string (19) "2013-12-01 00:00:00"
        ]
        '8' => array(2) [
            'reference' => string (5) "EE817"
            'start_date' => string (19) "2013-11-27 00:00:00"
        ]
        '9' => array(2) [
            'reference' => string (5) "EE817"
            'start_date' => string (19) "2013-11-27 00:00:00"
        ]
        '10' => array(1) [
            'file' => object SplFileInfo D:\xampp\htdocs\HawardSolutions
        ]
        '11' => array(1) [
            'file' => NULL
        ]
        '12' => array(1) [
            'file' => NULL
        ]
        '13' => array(1) [
            'file' => NULL
        ]
        '14' => array(1) [
            'file' => NULL
        ]
        '15' => array(1) [
            'file' => NULL
        ]
        '16' => array(1) [
            'file' => NULL
        ]
    ]
]

正如您所看到的,'file'键未在关联数组[id] [file]上合并。

我想在'数据'键上实现的是

'data' => array(14) [
        '3' => array(2) [
            'reference' => string (5) "IE928"
            'start_date' => string (19) "2013-10-27 00:00:00"
            'file' => object SplFileInfo D:\xampp\htdocs\HawardSolutions
        ]
        '4' => array(2) [
            'reference' => string (5) "FE160"
            'start_date' => string (19) "2013-12-15 00:00:00"
            'file' => object SplFileInfo D:\xampp\htdocs\HawardSolutions
        ]
        '5' => array(2) [
            'reference' => string (5) "EE817"
            'start_date' => string (19) "2013-11-24 00:00:00"
            'file' => object SplFileInfo D:\xampp\htdocs\HawardSolutions
        ]

提前致谢。

0 个答案:

没有答案