additional hidden field with radio button set default value in yii2

additional hidden field with radio button set default value in yii2

you will see yii automatically adds hidden field with each radio button and checkbox , you can set its default value by following code

<?= $form->field($model, 'session_frequency_id')->radio(['uncheck' => 1, 'label' => 'Daily', 'value' => 1, 'class' => 'icheck toggle-able sessionhost-session_frequency_id' ] ) ?>

in above code uncheck => 1 will set hidden field value .

yii 2 ajax call

 $.ajax({
            url: Yii.createUrl('/site/save-session-notification'),
            type: 'POST',
            data: {
                notification_read_status: checkbox_val,
                notification_type_id:'2'
             },                        
            success: function (data) {
              console.log("response here");
            },
            error: function (error) {
              console.log(error);
            }
        });
public function actionSaveSessionNotification()
    {
        print_r($_POST);
        die("====");
    }