Skip to content

Implement form submission #178

Open
@nicoburns

Description

Suggested implementation plan

  • Modify Navigate event to take a Request rather than a Url
  • Form submission should be triggered on:
    • Click of <input type="submit" />
    • Enter key press when single-line text-field is focussed
  • Write a submission function that:
    • Iterates up the tree from the element that triggered the event looking for a <form> element (if no <form> element is found then do nothing)
    • Reads the action and method from the <form>
    • Searches the subtree under the <form> for input elements (we currently support: text, textarea, radio, checkbox, and hidden).
    • Composes a url and body from form attrs and input values.
    • Generates a Navigate event.

The initial implementation:

  • Wouldn't necessarily need to support all types (maybe just text and hidden?)
  • Wouldn't necessarily need to generate a "submit" event for Dioxus Native
  • Could assume enctype of application/x-www-form-urlencoded. But should maybe check for multipart/form-data and do nothing / log warning if it is set.

Although of course these features could be implemented (although probably no point doing multipart encoding until we have file inputs)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions