Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rosa 17 posts 121 karma points
    Dec 04, 2023 @ 19:14
    Rosa
    0

    Umbraco Forms - how to add TempData if ModelState is invalid

    I'm using a blocklist editor with a Form component (that simply has a title and Form Picker) in my U10 project.

    If the user doesn't fill in the form correctly, I need the form to return TempData, for example TempData["Invalid"] so that I can check this on the front end and then show a notification that the form was not filled out correctly. I am also needing to include some javascript if the form is invalid so that the browser window will move to the top of the form component.

    I am using a tag helper to render my form:

    <umb-forms-render form-id="@Model" exclude-scripts="true" />
    

    How can I make it so I am returning this TempData? Do I need to implement a view component or something?

Please Sign in or register to post replies

Write your reply to:

Draft