question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include Submit button automatically?

See original GitHub issue

Hey guys,

I made a template for an existing package with this Django code:

<form method="POST">
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Sign Up" class="btn btn-primary">
</form>

I’d like to use bootstrap templating of Crispy forms, but when I do this

<form method="POST">
    {% crispy form %}
    <input type="submit" value="Sign Up" class="btn btn-primary">
</form>

Crispy forms renders the submit button outside the form tags and the form is useless:

<form method="POST">
    <input type="hidden" name="csrfmiddlewaretoken" value="...">...
    <input ... name="first_name" type="text"> ...
    <input ... name="last_name" type="text">...
    <input ... name="email" type="email">...
    <input ... name="password1" type="password">
</form>
<input type="submit" value="Sign Up" class="btn btn-primary">

Do I miss a feature of Crispy forms? How do you solve this without writing a custom form for the 3rd party package. Thanks in advance.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
carltongibsoncommented, Jan 13, 2017

The crispy tag takes a FormHelper as an optional second argument. If you set form_tag = False on that helper (I think) you should get what you want.

Review crispy tag docs — there are a lot of examples there.

(I’m guessing you’re getting two form elements rendered — the one in your template plus the one from crispy. Either remove you own ones and add a Submit element to the helper or disable the helper’s form_tag)

0reactions
lggwettmanncommented, Feb 3, 2017

Thanks, guys. I created a generic Form with just one FormHelper which disables the form_tag like @carltongibson suggested. The power of the crispy forms tag shouldn’t be underestimated 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable form auto submit on button click - Stack Overflow
Buttons like <button>Click to do something</button> are submit buttons. Set type="button" to change that. type="submit" is the default (as specified by the ...
Read more >
Automatically execute the "Submit" button - CodeProject
"Automatically execute" means: sending an HTTP request with the URL defined by the URL written as a value of the attribute action and, ......
Read more >
<input type="submit"> - HTML: HyperText Markup Language
An <input type="submit"> element's value attribute contains a string which is displayed as the button's label. Buttons do not have a true ...
Read more >
How to auto submit form without using Submit button? - Jotform
You would need to insert javascript code with full source code of your form to your webpage. This way your embedded form B...
Read more >
HTML Form – Input Type and Submit Button Example
You use this type to add a submit button to forms. When a user clicks it, it automatically submits the form. It takes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found