Hi!
Why im a getting this error in my view??
Controller------
public function createPost(PostRequest $request){
$userInput = $request->get('input');
return view('index',compact('userInput'));
}
View-----
@extends('welcome')
@section('content')
{!!Form::open(array('url' => '/index', 'method' =>'post'))!!}
{!!Form::text('input',null)!!}
{!!Form::submit('Send')!!}
{!!Form::close()!!}
<h1>{{$userInput}}</h1>
@stop
I dont understand..and here is my PostRequest class:
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
class PostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'input' =>'required'
];
}
}
why is the variable undifined when i post a empty form, why isnt the validation kicking off?
Try this in view:
@if (isset($userInput))
<h1>{{$userInput}}</h1>
@endif
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community