1

I am trying to do something like this-

<select name="project_type_id" class="form-control select-styled">
   <option value=0>Please Select a Project Type</option>
   @foreach ($project_types as $project_type)
       <option
            @if ( isset( Request::old('project_type_id') ) )
                strcmp(Request::old('project_type_id'),$project_type->id) ? "" : 'selected'
            @else
                strcmp($current_project->project_type_id,$project_type->id) ? "" : 'selected'
            @endif
           value="{{ $project_type->id }}">
           {{ $project_type->name }}
       </option>
   @endforeach
</select>

In Blade Template Engine.

But I am getting some error like this-

enter image description here

What I am doing wrong?

Can anyone please help?

lagbox
  • 48,571
  • 8
  • 72
  • 83
Abrar Jahin
  • 13,970
  • 24
  • 112
  • 161
  • 1
    Don't use isset() with Request::old('project_type_id') – Yurich Feb 07 '16 at 13:40
  • 2
    Possible duplicate of [Compile Error: Cannot use isset() on the result of an expression](http://stackoverflow.com/questions/29636880/compile-error-cannot-use-isset-on-the-result-of-an-expression) – Mazzy Feb 07 '16 at 14:18

1 Answers1

3

The error is pretty self-explanatory. This is not specific to blade. The function isset() is used to determine if a variable has been set, you are checking a function call.

You don't need the isset(), just use:

@if ( Request::old('project_type_id') )
Devon Bessemer
  • 34,461
  • 9
  • 69
  • 95