Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Shivamyadav's avatar

why not getting the checked value ?

my code on edit page

 <input name="gender" value="Male" value="<?php echo $students['gender'] ? 'checked' : '' ?>" class=" border border-black rounded-full py-5 px-3 mr-16 " id="grid-first-name" type="radio">
0 likes
7 replies
Nakov's avatar

You are setting the value as checked but checked is an attribute.. try this:

<input name="gender" value="Male" <?php echo $students['gender'] ==='Male'  ? 'checked' : '' ?> class=" border border-black rounded-full py-5 px-3 mr-16 " id="grid-first-name" type="radio">
Nakov's avatar

@Shivamyadav if you print out the value of the gender what does it says?

Add this above the input in your view:

@dd($students['gender'])
Nakov's avatar

@Shivamyadav instead of checked change it to selected. BTW I hope you don't have any JavaScript code related to the input fields that is changing your state. Otherwise one of those two should work, I don't see any other reason.

Nakov's avatar

@Shivamyadav haha, great job. It is good to share how you solved it, maybe it will help someone else.

Please or to participate in this conversation.