Support the ongoing development of Laravel.io →
Requests Input Forms

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?

Last updated 3 years ago.
0

why are you passing what you just requested?

0

Try this in view:

@if (isset($userInput))
    <h1>{{$userInput}}</h1>
@endif
0

Sign in to participate in this thread!

Eventy

Your banner here too?

spoofy spoofy Joined 27 Apr 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.