Don't miss out Virtual Happy Hour this Friday (April 26).
Try our conversational search powered by Generative AI!
AI OnAI Off
Don't miss out Virtual Happy Hour this Friday (April 26).
Anyone not come across this?
Not even the "native" DisplayTemplate view gives a value on form posting.
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)
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?