Php 如果不工作,则需要Laravel\u

Php 如果不工作,则需要Laravel\u,php,laravel,laravel-4,Php,Laravel,Laravel 4,如果验证不起作用,我需要的\u。选择“双人”但未选择“队友2和对手2”时,不会输出错误。当双打被选为比赛类型时,我需要表格来要求另一个队友和对手 Match.php(模型) 匹配创建视图 {{ Form::open(array('url'=>'members/matches/create', 'action' => 'post', 'class'=>'form-horizontal')) }} {{ form::hidden('id', Auth

如果验证不起作用,我需要的\u。选择“双人”但未选择“队友2和对手2”时,不会输出错误。当双打被选为比赛类型时,我需要表格来要求另一个队友和对手

Match.php(模型)

匹配创建视图

        {{ Form::open(array('url'=>'members/matches/create', 'action' => 'post', 'class'=>'form-horizontal')) }}
        {{ form::hidden('id', Auth::user()->id) }}
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Match Type</label>
            <div class="col-sm-7 col-sm-pad">
                {{ $errors->first('match_type', '<span class="help-block">:message</span>') }}
                {{ Form::select('match_type', array('singles' => 'Singles', 'doubles' => 'Doubles'), 'singles', array('id' => 'match_type', 'class' => 'form-control input')) }}
            </div>
        </div>
        <div class="form-group">
            <label for="gender" class="col-sm-5 control-label col-sm-pad">League Associate</label>
            <div class="col-sm-7 col-sm-pad">
                {{ $errors->first('associate', '<span class="help-block">:message</span>') }}
                {{ Form::text('associate', Input::old('associate'), array('class' => 'form-control input')) }}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Team Mate #1<br><small></small></label>
            <div class="col-sm-7 col-sm-pad">
                <p class="form-control-static">{{ Auth::user()->first_name." ".Auth::user()->last_name }}</p>
            </div>
        </div>
        <div class="form-group{{ $errors->first('opponent', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Opponent #1</label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::select('opponent', $users, 'key', array('class' => 'form-control input')) }}
                {{ $errors->first('opponent', '<span class="help-block">:message</span>') }}
            </div>
        </div>
        <div class="form-group{{ $errors->first('team_mate2', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Team Mate #2<br><small>(Doubles Only)</small></label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::select('team_mate2', $users, 'key', array('class' => 'form-control input')); }}
                {{ $errors->first('team_mate2', '<span class="help-block">:message</span>') }}
            </div>
        </div>
        <div class="form-group{{ $errors->first('opponent2', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Opponent #2<br><small>(Doubles Only)</small></label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::select('opponent2', $users, 'key', array('class' => 'form-control input')) }}
                {{ $errors->first('opponent2', '<span class="help-block">:message</span>') }}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Date</label>
                {{ $errors->first('day', '<span class="help-block">:message</span>') }}
                <div class="col-lg-2 col-sm-pad">
                    {{ Form::selectRange('day', 1, 31, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
                </div>
                <div class="col-lg-2 col-sm-pad">
                    {{ Form::selectRange('month', 1, 12, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
                </div>
                <div class="col-lg-3 col-sm-pad">
                    {{ Form::selectRange('year', 2014, 2015, 'a', array('class' => 'form-control input-sm input dob-form-control')) }}
                </div>
        </div>
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Time</label>
            <div class="col-lg-3 col-sm-pad">
                {{ Form::select('time', $times, 'key', array('class' => 'form-control input input-sm dob-form-control')) }}
            </div>
        </div>
        <div class="form-group{{ $errors->first('location', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Location</label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::text('location', Input::old('location'), array('class' => 'form-control input')) }}
                {{ $errors->first('location', '<span class="help-block has-error">:message</span>') }}
            </div>
        </div>
        {{ Form::submit('Create', array('class'=>'btn btn-success btn-block')) }}
        {{ Form::token() . Form::close() }}
{{Form::open(数组('url'=>'members/matches/create','action'=>'post','class'=>'Form-horizontal'))}
{{form::hidden('id',Auth::user()->id)}
匹配类型
{{$errors->first('match_type',':message')}
{Form::select('match_type',array('singles'=>'singles','doubles'=>'doubles'),'singles',array('id'=>'match_type','class'=>'Form control input'))}
团员
{{$errors->first('associate',':message')}
{{Form::text('associate',Input::old('associate'),array('class'=>'Form control Input'))}
队友#1

{{Auth::user()->first_name.”.Auth::user()->last_name}

对手#1 {{Form::select('opporter',$users,'key',array('class'=>'Form control input'))} {{$errors->first('对手',':message')} 队友2(仅双打) {{Form::select('team_mate2',$users,'key',array('class'=>'Form control input'));} {{$errors->first('team_mate2',':message')} 对手#2
(仅双打) {{Form::select('opponent2',$users,'key',array('class'=>'Form control input'))} {{$errors->first('opponent2',':message')} 日期 {{$errors->first('day',':message')} {{Form::selectRange('day',1,31,'a',array('class'=>'Form control input sm dob Form control'))} {{Form::selectRange('month',1,12,'a',array('class'=>'Form control input sm dob Form control'))} {Form::selectRange('year',2014,2015,'a',array('class'=>'Form control input sm input dob Form control'))} 时间 {{Form::select('time',$times,'key',array('class'=>'Form control input sm dob Form control'))} 位置 {{Form::text('location',Input::old('location'),array('class'=>'Form control Input'))} {{$errors->first('location',':message')} {{Form::submit('Create',array('class'=>'btn btn success btn block'))} {{Form::token().Form::close()}}
当我不使用这样的模型时:

$validator = Validator::make(
    array('match_type' => Input::get('match_type')),
    array('opponent' => 'required_if:match_type,doubles')
);
这似乎奏效了。我仍然不确定为什么我的方法不起作用,如果在模型中,匹配类型值是否不会传递到必需类型

        {{ Form::open(array('url'=>'members/matches/create', 'action' => 'post', 'class'=>'form-horizontal')) }}
        {{ form::hidden('id', Auth::user()->id) }}
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Match Type</label>
            <div class="col-sm-7 col-sm-pad">
                {{ $errors->first('match_type', '<span class="help-block">:message</span>') }}
                {{ Form::select('match_type', array('singles' => 'Singles', 'doubles' => 'Doubles'), 'singles', array('id' => 'match_type', 'class' => 'form-control input')) }}
            </div>
        </div>
        <div class="form-group">
            <label for="gender" class="col-sm-5 control-label col-sm-pad">League Associate</label>
            <div class="col-sm-7 col-sm-pad">
                {{ $errors->first('associate', '<span class="help-block">:message</span>') }}
                {{ Form::text('associate', Input::old('associate'), array('class' => 'form-control input')) }}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Team Mate #1<br><small></small></label>
            <div class="col-sm-7 col-sm-pad">
                <p class="form-control-static">{{ Auth::user()->first_name." ".Auth::user()->last_name }}</p>
            </div>
        </div>
        <div class="form-group{{ $errors->first('opponent', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Opponent #1</label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::select('opponent', $users, 'key', array('class' => 'form-control input')) }}
                {{ $errors->first('opponent', '<span class="help-block">:message</span>') }}
            </div>
        </div>
        <div class="form-group{{ $errors->first('team_mate2', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Team Mate #2<br><small>(Doubles Only)</small></label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::select('team_mate2', $users, 'key', array('class' => 'form-control input')); }}
                {{ $errors->first('team_mate2', '<span class="help-block">:message</span>') }}
            </div>
        </div>
        <div class="form-group{{ $errors->first('opponent2', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Opponent #2<br><small>(Doubles Only)</small></label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::select('opponent2', $users, 'key', array('class' => 'form-control input')) }}
                {{ $errors->first('opponent2', '<span class="help-block">:message</span>') }}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Date</label>
                {{ $errors->first('day', '<span class="help-block">:message</span>') }}
                <div class="col-lg-2 col-sm-pad">
                    {{ Form::selectRange('day', 1, 31, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
                </div>
                <div class="col-lg-2 col-sm-pad">
                    {{ Form::selectRange('month', 1, 12, 'a', array('class' => 'form-control input input-sm dob-form-control')) }}
                </div>
                <div class="col-lg-3 col-sm-pad">
                    {{ Form::selectRange('year', 2014, 2015, 'a', array('class' => 'form-control input-sm input dob-form-control')) }}
                </div>
        </div>
        <div class="form-group">
            <label class="col-sm-5 control-label col-sm-pad">Time</label>
            <div class="col-lg-3 col-sm-pad">
                {{ Form::select('time', $times, 'key', array('class' => 'form-control input input-sm dob-form-control')) }}
            </div>
        </div>
        <div class="form-group{{ $errors->first('location', ' has-error') }}">
            <label class="col-sm-5 control-label col-sm-pad">Location</label>
            <div class="col-sm-7 col-sm-pad">
                {{ Form::text('location', Input::old('location'), array('class' => 'form-control input')) }}
                {{ $errors->first('location', '<span class="help-block has-error">:message</span>') }}
            </div>
        </div>
        {{ Form::submit('Create', array('class'=>'btn btn-success btn-block')) }}
        {{ Form::token() . Form::close() }}
$validator = Validator::make(
    array('match_type' => Input::get('match_type')),
    array('opponent' => 'required_if:match_type,doubles')
);