Hanush Haridas
Hanush Haridas

Reputation: 23

I have an issue with radio button in laravel / HTML

I need my radio button checked in laravel. But i don't know how to fix it.

{!! Form::radio('self_paid','no',null, ['class' => 'company_paid'])   !!} 

I need this radio button to be checked by default.

Upvotes: 0

Views: 877

Answers (3)

Natvarsinh Parmar - bapu
Natvarsinh Parmar - bapu

Reputation: 1138

If you want to by default checked then :

{!! Form::radio('self_paid','no',true, ['class' => 'company_paid'])   !!}

If you want to radio button checked unchecked based on the value of a variable

In controller:

    public function index(){
        // variable value for checked radio button (true or 1)         
        $radio_checked = 1; 

        return view('your-blade-view', compact('radio_checked'));
    }

In blade file:

 {!! Form::radio('self_paid','no',$radio_checked, ['class' => 'company_paid'])   !!}

Upvotes: 2

Mon Mohon Singha
Mon Mohon Singha

Reputation: 64

Laravel Syntax:

Form::radio('name', 'value', true);

use:

{!! Form::radio('self_paid','no',true, ['class' => 'company_paid'])   !!}

Upvotes: 0

akshaypjoshi
akshaypjoshi

Reputation: 1295

Instead of null, you should use true. It accepts boolean value.

{!! Form::radio('self_paid','no',true, ['class' => 'company_paid'])   !!} 

Check this Radio Button

Upvotes: 1

Related Questions