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

When pressing enter to save, inline actions executes instead of saving #44

Open
tony opened this issue Mar 25, 2021 · 3 comments
Open

Comments

@tony
Copy link
Contributor

tony commented Mar 25, 2021

Edit any normal field value and press Enter

It will run the first django inline action rather than save the form

I believe this is due to how input type "submit" works. It's before the save button (Unless I'm missing something?)

ideas:

  • Instead of using a button / form at all, Link to an action URL with a GET param of the object ID, redirect back to the model page with a notification message
  • Render buttons type="button" and have an onClick() handler:
    '<input type="submit" name="{}" value="{}" class="{}">'.format(
  • Find a way to move the submit-row higher in HTML (but visually keep it at the button of the page)
@escaped
Copy link
Owner

escaped commented Mar 25, 2021

Good find. Not sure what the best way to solve this. A quick search brought up this: https://stackoverflow.com/questions/925334/how-is-the-default-submit-button-on-an-html-form-determined (leaving it here for reference).

@tony
Copy link
Contributor Author

tony commented Mar 25, 2021

@escaped My current best idea (not tested yet) is to use ModelAdmin.get_urls() and link to a page that runs the actions and redirects back. It could accept url routing and GET params.

@escaped
Copy link
Owner

escaped commented Apr 7, 2021

I see. You are thinking about using a simple link instead of a button, right?

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

No branches or pull requests

2 participants