将输入(表单)从页面传递到自身 [英] Passing input (form) from a page to itself
本文介绍了将输入(表单)从页面传递到自身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理我的第一个laravel脚本,试图提交表单并在同一页面上查看输入.我在这个问题上工作了好几天,希望有人能解决这个问题.问题是我收到此错误:
I am working on my first laravel script, trying to submit a form and see the input on the same page. I am working on this problem for days, hopefully someone can solve this. The problem is that i get this error:
Undefined variable: data (View: D:\Programmer\wamp\www\laravel\app\views\bassengweb.blade.php)
视图:Bassengweb.blade.index
view: Bassengweb.blade.index
@extends('master')
@section('container')
<h1>BassengWeb testrun</h1>
<table>
{{ Form::open(array('route' => 'bassengweb', 'url' => '/', 'method' => 'post')) }}
<tr>
<td>{{ Form::label('bassengId', 'Basseng ID')}}</td>
<td>{{ Form::text('bassengId') }}</td>
</tr>
<tr>
<td>{{ Form::label('frittKlor', 'Fritt Klor')}}</td>
<td>{{ Form::text('frittKlor') }}</td>
</tr>
<tr>
<td>{{ Form::label('bundetKlor', 'Bundet Klor')}}</td>
<td>{{ Form::text('bundetKlor') }}</td>
</tr>
<tr>
<td>{{ Form::label('totalKlor', 'Total Klor')}}</td>
<td>{{ Form::text('totalKlor') }}</td>
</tr>
<tr>
<td>{{ Form::label('ph', 'PH')}}</td>
<td>{{ Form::text('ph') }}</td>
</tr>
<tr>
<td>{{ Form::label('autoPh', 'Auto PH')}}</td>
<td>{{ Form::text('autoPh') }}</td>
</tr>
<tr>
<td>{{ Form::submit('Lagre målinger') }}</td>
{{ Form::close() }}
</table>
@if($data)
{{ $data->bassengId }}
@endif
@stop
Homecontroller.php
Homecontroller.php
<?php
class HomeController extends BaseController {
public function showWelcome()
{
return View::make('hello');
}
public function showTest()
{
return View::make('test');
}
public function getInput()
{
$input = Input::all();
print_r($input); die();
return View::make('bassengweb')->with('data', '$input');
}
}
视图:master.blade.php
view: master.blade.php
<div class="container">
@yield('container')
</div>
routes.php
routes.php
Route::get('/', function()
{
return View::make('bassengweb');
});
//Route::post('/', array('uses'=>'HomeController@getInput'));
Route::post('/',function(){
$input = Input::all();
//for inspecting input
print_r($input);
die();
//to send input to view but before sending to view comment last two lines
return View::make('bassengweb')->with('data',$input);
推荐答案
在您的routes.php
中,稍微更改路线注册.
In your routes.php
, change route registration a little.
Route::get('/', function()
{
$data = Input::all();
return View::make('bassengweb', compact('data'));
});
这篇关于将输入(表单)从页面传递到自身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文