Gender RadioButton default value on Registration

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 лет назад
In nopCommerce v3.80

I have set 'Gender' enabled = true in Configuration->Settings->Customer settings->Customer form fields.
But there is no associated setting for 'Gender' required.

Can I set the default value of the 'Gender' RadioButton on the Registration form to (say) 'M' by changing the Register.cshtml?

If so how do I code this?
What do I change in this code?

<div class="gender">
    <span class="male">
        @Html.RadioButton("Gender", "M", (Model.Gender == "M"), new { id = "gender-male" })
        <label class="forcheckbox" for="gender-male">@T("Account.Fields.Gender.Male")</label>
    </span>
    <span class="female">
        @Html.RadioButton("Gender", "F", (Model.Gender == "F"), new { id = "gender-female" })
        <label class="forcheckbox" for="gender-female">@T("Account.Fields.Gender.Female")</label>
    </span>
</div>

If it is not possible to do it this way, any other suggestions?
6 лет назад
Hello,

If you want pre select any option you can add new { Checked = "checked" }

Read more here

Thanks,
Jatin
6 лет назад
I have tried many different ways to include Checked="checked" all produced an error apart from the following:
@Html.RadioButton("Gender", "M", (Model.Gender == "M"), new { id = "gender-male" , Checked = "checked"} )

But the "Male" RadioButton is still not checked.

Any other ideas?
6 лет назад
We have decided to turn off the built-in Gender field and have created a Custom Customer Attribute for Gender as 'required' RadioButtons.

It would be nice if nopCommerce had a setting for 'Gender required' out-of-the-box as it does for other fields like 'Date of Birth', 'Street Address' etc..
6 лет назад
Good thoughts!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.