Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrchardCore.Forms doesn't preserve checked checkbox state when the checkbox doesn't have a default value #17023

Open
rjpowers10 opened this issue Nov 14, 2024 · 0 comments · May be fixed by #17024
Labels

Comments

@rjpowers10
Copy link
Contributor

Describe the bug

OrchardCore.Forms will store model state in a cookie so in the event the form is invalid the user can be redirected back to the form with the model state still intact.

Orchard Core version

Main branch as of 05bd65a

To Reproduce

  1. Create a new site using the blog recipe.
  2. Enable the OrchardCore.Forms feature.
  3. Add a new form widget to the "content" zone and "always" layer. In the form's flow:
    1. Add the Validation Summary widget.
    2. Add the Input widget.
      1. Name: MyName
      2. ID: MyName
      3. Label option: Standard
      4. Label text: Name
      5. Type: Input
      6. Validation option: Standard
    3. Add the Input widget.
      1. Name: MyCheckbox
      2. ID: MyCheckbox
      3. Label option: Standard
      4. Label text: Click me
      5. Type: Checkbox
      6. Validation option: Standard
    4. Add the Button widget
      1. Name: MyButton
      2. ID: MyButton
      3. Text: Submit
      4. Type: Submit
    5. Add a new workflow like the image below. The idea is to submit the form and force a validation error on the checkbox, then redirect back to the form to display the error.
    6. Copy the action from the Http Request Event and set that as the form action back in the form widget.
    7. Uncheck "validate antiforgery token" from the Http Request Event.

If you get stuck I modified the example "contact" form from the OC docs

image

View the form
image

Fill out the form
image

Submit the form. The text input state is preserved. The checkbox state is not preserved.
image

Expected behavior

Checkbox state is preserved across the redirect (the checkbox remains checked if it was checked when submitted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant