Laravel请求为空?

时间:2017-10-11 12:03:21

标签: javascript jquery laravel laravel-5

我通过这样的jquery生成一个输入:

marker = new google.maps.Marker({
    map: map,
    position: results[0].geometry.location,
    title: address,
    draggable: true,
    zoom: 19,
    icon: pinImages,
    shadow: pinShadows
});
lat = results[0].geometry.location.lat();
lng = results[0].geometry.location.lng();
$("#lng").html("<input type=hidden name=lng value=" + lng + ">");
$("#lat").html("<input type=hidden name=lat value=" + lat + ">");
google.maps.event.addListener(marker, 'dragend', function (marker) {
    latLng = marker.latLng;
    lat = latLng.lat();
    lng = latLng.lng();
    $("#lng").html("<input type=hidden name=lng value=" + lng + ">");
    $("#lat").html("<input type=hidden name=lat value=" + lat + ">");
});

在html中看起来像:

<div id="lat" value="53.486755"><input type="hidden" name="lat" value="53.4867546"></div>

<div id="lng" value="-2.054067"><input type="hidden" name="lng" value="-2.054066599999942"></div>

对我来说看起来绝对没问题。现在提交表单时,控制器被调用:

public function updateEntity(EntityRequestUpdate $request)
{
          dd($request->input('lat'));

但是数据转储给了我null。为什么会这样?

EntityRequestUpdate:

public function rules()
{
    return [
        'name' => 'required|min:3|max:100',
        'type' => 'required|exists:entity_types,type',
        'email' => 'required|email|max:100',
        'building_name' => 'nullable',
        'address' => ['required','max:191', new Address],
        'town' => ['required','max:191', new Hyphens],
        'postcode' => ['required','max:191', new Postcode],
        'telephone' => ['nullable','max:191', new Telephone],
        'ical' => 'nullable|active_url|max:191',
        'eventbrite' => 'nullable|numeric',
        'tags' => 'nullable|max:255',
        'url' => 'nullable|max:191',
        'video' => 'nullable|max:191',
        'bio' => 'nullable|max:500',
        'main' => 'nullable|max:2000',
        'lat' => 'nullable',
        'lng' => 'nullable'
    ];

0 个答案:

没有答案