【发布时间】:2017-05-23 03:48:13
【问题描述】:
我的申请中有一个表格。我还有一个使用vue-google-maps 创建输入字段的视图组件。
我在我的内部使用这个组件,但没有名称属性,所以我的服务器无法识别提交的值。
如何将输入字段中的数据提交到我的服务器?我正在使用 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>
我的 Laravel 表单如下所示:
{!! 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() !!}
其中 location-input 是生成输入的 vue-google-maps 组件。
当我提交表单并将数据转储到屏幕时,没有可用的位置数据!
在服务器上
$input = Request::all();
dd($input);
原始输入看起来像这样(组件上的 name 属性不会添加到输入字段):
如何将位置输入数据连同我的表单一起提交?
【问题讨论】:
-
这是现场直播吗?如果没有,能否显示生成的html?
-
使用生成的 html 的屏幕截图更新了 repo。它不是实时的,但代码仓库在 github 上:github.com/connor11528/laravel-5.3-app
标签: php laravel google-maps laravel-5 vue.js