Olasunkanmi
Olasunkanmi

Reputation: 333

Dropdown option not updating on the front end

I am working with Laravel 5.2. A portion of my form, I have to choose if a user is active or not. I hard coded a default user to be inactive in users table.

$table->integer('is_active')->default(0);
Choosing a user to be active or inactive still defaults to Active on the front end. Even though it enters it correctly in my database. Also when I edit the same user, it pulls the correct status from the database. But once I save it, I still get active on the front end. Here's my form

<div class="form-group">
        {!! Form::label('is_active','Status:') !!}
        {!! Form::select('is_active',[0=>'inactive',1=>'active'],0,['class'=>'form-control']) !!}

I have played around with it replacing the default value 0 with null like this

<div class="form-group">
        {!! Form::label('is_active','Status:') !!}
        {!! Form::select('is_active',[0=>'inactive',1=>'active'],null,['class'=>'form-control']) !!}

Still I get the same result.

Heres my table data for front end display.

<td>{{$user->is_active = 0 ? 'Inactive':'Active' }}</td>

Upvotes: 1

Views: 204

Answers (1)

M.Islam
M.Islam

Reputation: 151

Just change the condition operation like this. replace "=" by "==".

<td>{{$user->is_active == 0 ? 'Inactive':'Active' }}</td>

Upvotes: 4

Related Questions