Aug 26, 2013, 1:24 PM
[CLOSED] Form Validation with Checkboxgroup
Hi there,
I have a Formpanel containing many different Fields (Textfields, Textareas, Comboboxes, Radiogroups, ...).
Only Fields with changes in their value (isDirty flag) are submitted to the server and there is some remote validation, marking invalid Fields.
After saving I store the form's state by getForm().setValues(values) and by calling markAsValid for each Field.
This works fine so far but I encounter a problem with selected checkboxes for the setValues() function. They are keeping getting unchecked after the setValues() call:
I have a Formpanel containing many different Fields (Textfields, Textareas, Comboboxes, Radiogroups, ...).
Only Fields with changes in their value (isDirty flag) are submitted to the server and there is some remote validation, marking invalid Fields.
After saving I store the form's state by getForm().setValues(values) and by calling markAsValid for each Field.
This works fine so far but I encounter a problem with selected checkboxes for the setValues() function. They are keeping getting unchecked after the setValues() call:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript"">
function markFormPanelValid(formPanel) {
formPanel.cascade(function (f) {
if (f.clearInvalid) {
f.clearInvalid();
}
});
formPanel.getForm().setValues(formPanel.getForm().getValues());
}
</script>
</head>
<body>
@Html.X().ResourceManager()
@(Html.X().FormPanel()
.ID("FormPanel")
.Layout(LayoutType.Form)
.Title("FormPanel")
.TrackResetOnLoad(true)
.Buttons(
Html.X().Button().Text("Set Dirty").OnClientClick("App.Item_457.markInvalid('invalid');"),
Html.X().Button().Text("Clear").OnClientClick("markFormPanelValid(App.FormPanel);")
)
.Items(
Html.X().CheckboxGroup().ID("Item_456").Items(
Html.X().Checkbox().Name("Item_456").BoxLabel("Input 1").InputValue("1").UncheckedValue("-1"),
Html.X().Checkbox().Name("Item_456").BoxLabel("Input 2").InputValue("2").UncheckedValue("-2"),
Html.X().Checkbox().Name("Item_456").BoxLabel("Input 3").InputValue("3").UncheckedValue("-3"),
Html.X().Checkbox().Name("Item_456").BoxLabel("Input 4").InputValue("4").UncheckedValue("-4")
),
Html.X().TextField().ID("Item_457")
)
)
</body>
</html>
Is there a workaround for the checkboxes?
Last edited by Daniil; Aug 27, 2013 at 3:44 AM.
Reason: [CLOSED]