Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp 3.0 form element radio button selected issue

I am facing problem in edit mode.

The radio button is not showing as selected.

This is my code

    <div class="control-group required"><label class="control-label"><?php echo __('status') ?></label><div class="controls">
            <?php

            $attributes = array(
                'selected' => 1
            );
            echo $this->Form->radio(
                    'status', $statusData,$attributes
            );
            ?>
            <span id="error" class="error"></span>
        </div>

    </div>
like image 290
JPT Avatar asked Jun 18 '26 09:06

JPT


1 Answers

try this please:

$attributes = array(
   'value' => '1'
);

$statusData = array(
   '1' => 'Yes', '0' => 'No'
);

echo $this->Form->radio(
   'status', $statusData,$attributes
);
like image 112
Alessandro Minoccheri Avatar answered Jun 23 '26 09:06

Alessandro Minoccheri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!