Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How do you check a checkbox by default in your form?
Been reading about "hacking" source to do this. Hopefully this is not nessecary on a paid pro module?
Comment author was deleted
Just set the default value to true
I did but that does not make it checked.
Ok looks like it's a bug, will release an update today but to fix it you can simply update
@if(Model.ContainsValue(true) || Model.ContainsValue("true"))
where it says
Great but one minor bug. If you don't fill out a mandatory field and hit submit it leaves the checkbox now "un-checked."
Ok issue added to the issue tracker http://issues.umbraco.org/issue/CON-356
I have the same problem with checkboxes being unchecked, if the form fails to be submitted. Any chance of a workaround?
Yeah update the \Umbraco\Contour\Code WEBFORMS\FormsSampleSite\Umbraco\Plugins\umbracoContour\Views\FieldType.CheckBox.cshtml file
and where it says @if (Model.ContainsValue(true)) add || Model.ContainsValue("on")
Thanks but that doesn't seem to work when you have defined a default value. Then the checkbox is always selected, also when its unselected.
Used the following workaround:
bool isChecked = IsPost ? Request.Form[Model.Id] == "on" : Model.ContainsValue("true");
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted