Try our conversational search powered by Generative AI!

No value from checkboxes in xform postdata

Vote:
 

When posting a xform value from checkbox is always empty.

 

The view (SelectFragment.cshtml) looks like this:

@using EPiServer.XForms.Parsing
@model SelectFragment@foreach (SelectOption selectoption in Model.Options)

{
<div class="checkbox @(Model.Class.IsEmpty() ? "col-sm-12" : Model.Class)">
<label for="@selectoption.Id">
@Html.CheckBox(Model.Reference, selectoption.SelectedItem, new { id = selectoption.Id })
@Html.Raw(selectoption.Text)
</label>
</div>
}
@Html.ValidationMessage(Model.Reference)

 

Any ideas?

#85142
Apr 16, 2014 10:48
Vote:
 

Anyone not come across this?
Not even the "native" DisplayTemplate view gives a value on form posting.

#85534
Apr 29, 2014 11:36
Vote:
 

I removed the DisplayEditor view for SelectFragment and started over which solved the problem.

Must have been an error in the markup somewhere.

Below is the working razor view for SelectFragment.cshtml

@using EPiServer.XForms.Parsing
@model SelectFragment

<fieldset>
        @foreach (SelectOption selectoption in Model.Options)
        {
            <div class="checkbox @(Model.Class.IsEmpty() ? "col-sm-12" : Model.Class)">
                <label>
                    <input id="@selectoption.Id" name="@selectoption.Id" type="checkbox" value="true">
                    <input name="@selectoption.Id" type="hidden" value="false">
                    @selectoption.Value
                </label>
            </div>
        }

</fieldset>

@Html.ValidationMessage(Model.Reference)

    

 

#85855
May 07, 2014 11:18
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.