PHP数组绑定回html表单值

时间:2017-09-05 05:48:07

标签: php html arrays laravel-5

我有一系列值,其中包含一个名为 parameter_list 的列表,其中包含 有一组值,这些值需要通过html表单更新。 数组值如下所述。

array:2 [▼
  0 => {#289 ▼
    +"Group1Name": {#285 ▼
      +"test1id": {#281 ▼
        +"name": "test1name"
        +"external_lab": "labname"
        +"parameter_list": array:2 [▼
          0 => {#282 ▼
            +"parameter": "PHM"
            +"observed_value": ""
            +"unit": "pmol/mm"
            +"normal": ""
            +"min": ""
            +"max": ""
            +"ref_notes": ""
          }
          1 => {#283 ▼
            +"parameter": "PHM"
            +"observed_value": ""
            +"unit": "pmol/mm"
            +"normal": ""
            +"min": ""
            +"max": ""
            +"ref_notes": ""
          }
        ]
        +"attachments": {#284 ▶}
      }
      +"test2id": {#286 ▼
        +"name": "test2name"
        +"external_lab": "labname"
        +"parameter_list": array:1 [▼
          0 => {#287 ▼
            +"parameter": "PHM"
            +"observed_value": ""
            +"unit": "pmol/mm"
            +"normal": ""
            +"min": ""
            +"max": ""
            +"ref_notes": ""
          }
        ]
        +"attachments": {#288 ▶}
      }
    }
  }
  1 => {#295 ▼
    +"Group2Name": {#292 ▼
      +"test1id": {#290 ▼
        +"name": "TEST1"
        +"parameter_list": array:1 [▶]
      }
      +"test2id": {#293 ▼
        +"name": "TEST2"
        +"parameter_list": array:1 [▶]
      }
    }
  }
]

我通过输入标记获取表单中的值,如下所示,

 @foreach($valBookingDetails as $key => $val)
                                <?php $count=-1; ?>
                                @foreach($val->lab_appointment_details->test_details as $k=> $subVal)
                                    @foreach($subVal as $k2 => $sub2Val)
                                        <?php $count++; ?>
                                        <tr class="test-report-header">
                                            <td><input  type="checkbox" class="filled-in chk-blood-main-item" id="chkFullBloodReport" /> <label for="chkFullBloodReport" class="lbl-for-checkbox" style="padding: 8px;">&nbsp;</label></td>
                                            <td class="test-report-header-title">

                                                {{ $k2 }}</td>
                                            <td></td>
                                            <td><textarea type="text" class="text-center testlab-report-textarea materialize-textarea" style="visibility: hidden;"  ></textarea></td>
                                            <td><span class="hide">mmg</span></td>
                                            <td><span class="hide">12 - 15</span></td>
                                            <td><textarea type="text" class="text-center testlab-report-textarea materialize-textarea" style="visibility: hidden;"  ></textarea></td>
                                            <td>
                                                <input multiple="true" type="file" id="upload1" class="testlab-report-upload" accept=".jpg,.jpeg,.png,.gif,.pdf" />
                                                <div class="uploaded-report-container">
                                                    <span class="img-addMore"><img src="<?php echo url('../images/addMore.png');?>" /></span>
                                                </div>
                                            </td>
                                        </tr>

                                        @foreach($sub2Val as $k3=> $sub3Val)
                                            <input type="hidden" name="groupname[<?php echo $k2?>][]" value="<?php echo $sub3Val->name; ?>">
                                            <?php $spancount=0; ?>
                                            @foreach($sub3Val->parameter_list as $k4=> $sub4Val)
                                                <input type="hidden" name="groupname[<?php echo $k2?>][<?php echo $k4 ?>][param]" value="<?php echo $sub4Val->parameter; ?>">
                                                <input type="hidden" name="groupname[<?php echo $k2?>][<?php echo $k4 ?>][test]" value="<?php echo $sub3Val->name; ?>">
                                            <tr>
                                                <td><input type="checkbox" class="filled-in chk-blood-items" id="chkHemoglobinBloodReport" /><label for="chkHemoglobinBloodReport" class="lbl-for-checkbox" style="padding: 8px;">&nbsp;</label></td>
                                                @if($spancount == 0)
                                                    <?php $spancount++; ?>
                                                <td class="word-wrap" rowspan="{{ count($sub3Val->parameter_list)  }}">
                                                    {{ $sub3Val->name }}</td>
                                                @endif
                                                <td>{{ $sub4Val->parameter }}</td>
                                                <td><textarea type="text" class="text-center testlab-report-textarea materialize-textarea"  >{{ @$sub4Val->observed_value }}</textarea></td>
                                                <td> {{ $sub4Val->unit }}</td>
                                                <td><textarea type="text" class="text-center testlab-report-textarea materialize-textarea"  >{{ @$sub4Val->normal }}</textarea></td>
                                                <td><textarea type="text" class="text-center testlab-report-textarea materialize-textarea"  >{{ @$sub4Val->ref_notes }}</textarea></td>
                                                <td>
                                                    <input multiple="true" type="file" id="upload2" class="testlab-report-upload" accept=".jpg,.jpeg,.png,.gif,.pdf" />
                                                    <div class="uploaded-report-container">
                                                        <span class="img-addMore"><img src="<?php echo url('../images/addMore.png');?>" /></span>
                                                    </div>
                                                </td>
                                            </tr>
                                                @endforeach
                                            @endforeach
                                        @endforeach
                                    @endforeach
                                @endforeach
但是来自上述形式的值与数组中的值不同。

我希望通过表单获取具有新更新值的相同数组。但它没有形成,因为它是我检索的数组。

我想通过使用html表单

来形成如下所示的数组

array:2 [▼
  0 => {#289 ▼
    +"Group1Name": {#285 ▼
      +"test1id": {#281 ▼
        +"name": "test1name"
        +"external_lab": "labname"
        +"parameter_list": array:2 [▼
          0 => {#282 ▼
            +"parameter": "APHM"
            +"observed_value": "23.32"
            +"unit": "pmol/mm"
            +"normal": "12"
            +"min": "243"
            +"max": "22"
            +"ref_notes": "this test is counduct based on ..."
          }
          1 => {#283 ▼
            +"parameter": "PHM"
            +"observed_value": "12.3"
            +"unit": "pmol/mm"
            +"normal": "23"
            +"min": "34.3"
            +"max": "234.34"
            +"ref_notes": "this test is counduct based on ..."
          }
        ]
        +"attachments": {#284 ▶}
      }
      +"test2id": {#286 ▼
        +"name": "test2name"
        +"external_lab": "labname"
        +"parameter_list": array:1 [▼
          0 => {#287 ▼
            +"parameter": "PHM"
            +"observed_value": "12.3"
            +"unit": "pmol/mm"
            +"normal": "34.3"
            +"min": "344"
            +"max": "345"
            +"ref_notes": "this test is counduct based on ..."
          }
        ]
        +"attachments": {#288 ▶}
      }
    }
  }
  1 => {#295 ▼
    +"Group2Name": {#292 ▼
      +"test1id": {#290 ▼
        +"name": "TEST1"
        +"parameter_list": array:1 [▶]
      }
      +"test2id": {#293 ▼
        +"name": "TEST2"
        +"parameter_list": array:1 [▶]
      }
    }
  }
]

请帮我重新绑定数组中的表单值。

0 个答案:

没有答案