Saturday, March 11, 2017

Laravel checkbox always save as 1

There is checkbox in form

{!! Form::checkbox('is_explicit_content', '1', $post->is_explicit_content, ['id' => 'is_explicit_content']); !!} 
{!! Form::label('is_explicit_content', 'Explicit', ['class' => 'checkbox-label']) !!}

model

class Post extends Model
{
    protected $fillable = [
        'text',
        'is_explicit_content'
    ];
}

but value is always saved as 1 and I don't understand why? How to fix it?



via Heidel

Advertisement