Problem with HTML::radio()

This is the plain HTML that is working just fine:


<input type = "radio"

       name = "country"

       id = "engCnt"

       value = "eng"

       checked = "checked">

<label for = "engCnt">ENG</label>


<input type = "radio"

       name = "country"

       id = "gerCnt"

       value = "ger">

<label for = "gerCnt">GER</label>


<input type = "radio"

       name = "country"

       id = "allCnt"

       value = "all">

<label for = "allCnt">All</label>

I need to decide dynamically whether or not button should be checked and what should be it’s label based on the site language. I am not showing you that logic, because even without it I have a problem. This is the minimum Yii code that I use to generate radio buttons:


<?= HTML::radio('country', true, ['label' => 'ENG', 'id' => 'engCnt']) ?>

<?= HTML::radio('country', false, ['label' => 'GER', 'id' => 'gerCnt']) ?>

<?= HTML::radio('country', false, ['label' => 'ALL', 'id' => 'allCnt']) ?>

There are 2 problems with this code. First: ENG option is not checked by default. Second, I can not check manually anything. I have just 3 unchecked radio buttons, and I can not check any of them.

Am I missing something ?

I couldn’t reproduce the problem with the following code:




<?php use \yii\helpers\Html; ?>

...

    <?= Html::beginForm(); ?>

    <?= Html::radio("country", false, ['label' => "ENG", 'id' => 'engCnt']); ?>

    <?= Html::radio("country", true, ['label' => "GER", 'id' => 'gerCnt']); ?>

    <?= Html::radio("country", false, ['label' => "ALL", 'id' => 'allCnt']); ?>

    <?= Html::endForm(); ?>



I could set the initial check on "GER".

The code above produced something like the following:




<form action="/diary/index" method="post">

<input type="hidden" name="_csrf" value="MFh4RlpTOGxKK0ECNj9BI151ShRqC3wKBBA3DzcyYAFKNT43FDsVAg==">

<label><input type="radio" id="engCnt" name="country" value="1"> ENG</label>

<label><input type="radio" id="gerCnt" name="country" value="1" checked> GER</label>

<label><input type="radio" id="allCnt" name="country" value="1"> ALL</label>

</form>



I think that "value" attribute should be set properly like:




    <?= Html::radio("country", false, ['label' => "ENG", 'id' => 'engCnt', 'value' => 'ENG']); ?>

    <?= Html::radio("country", true, ['label' => "GER", 'id' => 'gerCnt', 'value' => 'GER']); ?>

    <?= Html::radio("country", false, ['label' => "ALL", 'id' => 'allCnt', 'value' => 'ALL']); ?>



[EDIT]

I mean that you did not write the minimum code that reproduces your issue. :)