Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel 3:使用输入()不保存输入_Php_Laravel_Laravel 3 - Fatal编程技术网

Php Laravel 3:使用输入()不保存输入

Php Laravel 3:使用输入()不保存输入,php,laravel,laravel-3,Php,Laravel,Laravel 3,我有一张拉威尔表格,通过了一些验证。显然,如果验证失败,我希望将用户重定向到表单,并警告他们的错误。另外,由于表单相当大,我不希望用户必须重新输入任何数据。这是表单(我已经剪掉了一大部分,以减少此消息的大小) 因此,当我通过故意使表单无效来测试这一点时,我被重定向到帐户/创建表单,但是,没有显示任何验证错误,并且没有保存旧的输入(我只将input::old()附加到amount文本框中)。结果是如果input::old()中的字符总数超过约1400个字符,事情变得有点麻烦。我通过在我的应用程序/

我有一张拉威尔表格,通过了一些验证。显然,如果验证失败,我希望将用户重定向到表单,并警告他们的错误。另外,由于表单相当大,我不希望用户必须重新输入任何数据。这是表单(我已经剪掉了一大部分,以减少此消息的大小)


因此,当我通过故意使表单无效来测试这一点时,我被重定向到帐户/创建表单,但是,没有显示任何验证错误,并且没有保存旧的输入(我只将
input::old()
附加到amount文本框中)。

结果是如果
input::old()中的字符总数
超过约1400个字符,事情变得有点麻烦。我通过在我的
应用程序/config/session.php
中将
'driver'=>'cookie'
更改为
'driver'=>'file'
解决了这个问题,它开始按预期工作


结果是,如果
Input::old()
中的字符总数超过了约1400个字符,就会出现一些问题。我通过在我的
应用程序/config/session.php
中将
'driver'=>'cookie'
更改为
'driver'=>'file'
解决了这个问题,它开始按预期工作


Var在验证后转储验证程序对象。让我们看看我们得到了什么。
object(Laravel\Messages)#31(2){[“Messages”]=>array(0){}[“format”]=>string(8)”:message“}
另外,当我在控制器中执行
Input::old()
var\u转储时,我看到了应该保存的值。但是,当我在视图中执行相同的
var\u dump
时,它返回空。所以我的控制器和视图之间丢失了一些东西,我不知道为什么.Var会在验证之后转储validator对象。让我们看看我们得到了什么。
object(Laravel\Messages)#31(2){[“Messages”]=>array(0){}[“format”]=>string(8)”:message“}
另外,当我在控制器中执行
Input::old()
var\u转储时,我看到了应该保存的值。但是,当我在视图中执行相同的
var\u dump
时,它返回空。所以我的控制器和我的视图之间丢失了一些东西,我不知道为什么。
:@layout('templates.main')

@section('content')
    @if(Session::has('validation_errors'))
    <ul class="form_errors">
        @foreach($errors as $error)
            {{$error}}
        @endforeach
    </ul>
    @endif

    {{ Form::open('account/create', 'POST') }}
    <table>
        <tr>
            <td>{{ Form::label('dealer', 'Dealer') }}</td>
            <td>{{ Form::select('dealer', array('1' => 'Dealer #1', '2' => 'Dealer #2')) }}</td>
            <td>{{ Form::label('amount', 'Amount') }}</td>
            <td>{{ Form::text('amount', Input::old('amount')) }}</td><!--Here is where I'm testing for old input-->
        </tr>
        <tr>
            <td>{{ Form::label('date', 'Date') }}</td>
            <td>{{ Form::date('date', NULL, array('class' => 'date_picker')) }}</td>
            <td>{{ Form::label('installation', 'Installation #') }}</td>
            <td>{{ Form::input('text', 'installation') }}</td>
        </tr>
        <tr>
            <td colspan="4">{{ Form::textarea('notebox', NULL, array('id' => 'notebox')) }}</td>
        </tr>
        <tr>
            <td colspan="4">{{ Form::submit('Submit') }}&nbsp;{{ Form::reset('Reset') }}</td>
        </tr>
    </table>
    {{ Form::close() }}
@endsection
public function post_create() {
        //Validate it in the model
        $validation = Account::validate(Input::all());
        if($validation->fails()){
            return Redirect::to('account/create')
                ->with_input()
                ->with('validation_errors', true)
                ->with('errors', $validation->errors->all('<li>:message</li>'));
        }
        else {
            return "passed";//for debugging purposes
        }
    }
class Account extends Eloquent { 
        public static function validate($input) {
            //Validation rules
            $rules = array(
                'firstname' => 'required',
                'lastname' => 'required',
                            //etc...
            );
            //Custom validation messages
            $messages = array(
                'firstname_required' => 'A first name is required.',
                'lastname_required' => 'A last name is required.',
                //etc...
            );
            //Pass it through the validator and spit it out
            return Validator::make($input, $rules, $messages);
        }
    }