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
Hey,
Just set the default value to true
I did but that does not make it checked.
http://thy360.dk/branding-af-thy/vind-en-ipad.aspx
Ok looks like it's a bug, will release an update today but to fix it you can simply update
\Umbraco\Plugins\umbracoContour\Views\FieldType.CheckBox.cshtml
and add
@if(Model.ContainsValue(true) || Model.ContainsValue("true"))
where it says
@if(Model.ContainsValue(true))
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?
CheersBjørn
@Bjorn,
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...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Checkbox checked at default
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
Hey,
Just set the default value to true
I did but that does not make it checked.
http://thy360.dk/branding-af-thy/vind-en-ipad.aspx
Comment author was deleted
Ok looks like it's a bug, will release an update today but to fix it you can simply update
\Umbraco\Plugins\umbracoContour\Views\FieldType.CheckBox.cshtml
and add
@if(Model.ContainsValue(true) || Model.ContainsValue("true"))
where it says
@if(Model.ContainsValue(true))
Great but one minor bug. If you don't fill out a mandatory field and hit submit it leaves the checkbox now "un-checked."
Comment author was deleted
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?
Cheers
Bjørn
Comment author was deleted
@Bjorn,
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.
Cheers
Bjørn
Used the following workaround:
Cheers
Bjørn
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.