Skip to content

Unable to build form with submit button from HTML #1770

@thohan88

Description

@thohan88

This may be intentional as I seem to remember there being some issues with submit buttons in shiny for R.

My use case was just a simple form POST with action attached, and I expected this to work:

from shiny import App, ui
from htmltools import HTML

app_ui = ui.page_auto(
    ui.h2("Login"),
    HTML(
        """
         <form action="/api/auth/web/login" method="POST">
            <input type="email" id="username" name="username">
            <input type="password" id="password" name="password">
            <button type="submit" class="btn btn-primary">Login</button>
        </form>
        """
    ),
)

def server(input, output, session):
    pass

app = App(app_ui, server)

Nothing happens when the button is clicked, and I can't find the cause. A pure HTML file seems to work fine:

<!DOCTYPE html>
<html>
    <body>
        <form action="/api/auth/web/login" method="POST">
            <input type="email" id="username" name="username">
            <input type="password" id="password" name="password">
            <button type="submit" class="btn btn-primary">Login</button>
        </form>
    </body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions