dongzhe6287 2017-01-08 22:30
浏览 52

如何将vue-google-maps placeInput提交给服务器?

I have a form in my application. I also have a view component that creates an input field using vue-google-maps.

I use this component within my but there is no name attribute so my server does not recognize a submitted value.

How can I submit the data from the input field to my server? I am using Laravel 5.3.

<template>

    <place-input
            :place.sync="placeInput.place"
            :types.sync="placeInput.types"
            :component-restrictions.sync="placeInput.restrictions"
            class='form-control'
            label='Location: '
            name='location'
    ></place-input>

    <pre>{{ placeInput.place | json }}</pre>

</template>

<script>
    import { PlaceInput, Map } from 'vue-google-maps'

    export default {

        data() {
            return {
                placeInput: {
                    place: {
                        name: ''
                    },
                    types: [],
                    restrictions: {'country': 'usa'}
                }
            }
        },

        components: {
            PlaceInput
        },

        ready() {
        }
    }
</script>
<style>
    label { display: block; }
</style>

My Laravel form looks like this:

{!! Form::open(['action' => 'CandidateController@store']) !!}
<div class='form-group'>
    {!! Form::label('email', 'Email:') !!}
    {!! Form::email('email', null, ['class' => 'form-control']) !!}
</div>

<div class='form-group'>
    {!! Form::label('phone', 'Phone:') !!}
    {!! Form::text('phone', null, ['class' => 'form-control']) !!}
</div>

<div class='form-group'>
    <location-input></location-input>
</div>
{!! Form::close() !!}

Where location-input is the vue-google-maps component that generates an input.

When I submit the form and dump the data to the screen no location data is available!

on server

$input = Request::all();
dd($input);

no data from location-input avail on server side

The raw input looks like this (the name attribute on the component does not add to the input field):

enter image description here

How do I submit the location-input data along with my form?

  • 写回答

2条回答 默认 最新

  • dongzhun8449 2017-01-08 22:46
    关注

    I'd still like to see your generated html but I think the problem is that there's no name attribute on the input you're creating. Thus, it's not part of the posted data.

    <place-input
            :place.sync="placeInput.place"
            :types.sync="placeInput.types"
            :component-restrictions.sync="placeInput.restrictions"
            class='form-control'
            name='location'
            label='Location: '
    ></place-input>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序