如何将表单文本清空?

时间:2016-04-12 12:34:40

标签: php html forms laravel

我不知道将表单文本留空的方法是没有结果。我需要这样的东西......

  

如果没有userCreator =表单文本为空

我的代码

<div class="col-md-4">
    <div class="form-group">
        {{ Form::label('userCreator','UserCreator') }}
        @if(isset($userCreator))
        @foreach($userCreator as $cs)
        {{ Form::text('userCreator',$cs->home_lastname,['class'=>'form-control']) }}
        @endforeach
        @else{ {{-- What should i put inside here ? --}}
        }
        @endif
    </div>
</div>

2 个答案:

答案 0 :(得分:2)

@if(isset($userCreator) && count($userCreator) > 0)
    <div class="col-md-4">
        <div class="form-group">
            {{ Form::label('userCreator','UserCreator') }}
            @foreach($userCreator as $cs)
            {{ Form::text('userCreator',$cs->home_lastname,['class'=>'form-control']) }}
            @endforeach
        </div>
    </div>
@endif

答案 1 :(得分:1)

试试这个......

<div class="col-md-4">
    <div class="form-group">
        {{ Form::label('userCreator','UserCreator') }}
        @if(!empty($userCreator))
          @foreach($userCreator as $cs)
            {{ Form::text('userCreator',$cs->home_lastname,['class'=>'form-control']) }}
          @endforeach
        @else
            {{ Form::text('userCreator','', ['class'=>'form-control']) }}
        @endif
    </div>
</div>