Looking at codes on the Internet I have found a form in a blade view like the following:
<form method="post" action="{{ route('grabar') }}">
@csrf
<input type="hidden" name="id" value="{{ $user->id }}">
<button class="btn btn-outline-primary btn-sm">Enviar</button>
</form>
I have tried it and it works. And my question is why does it work? The button is not submit
, but a button with no specific action assigned (there is no javascript to read the event of pressing it, or anything like that), and instead it acts by submitting the form. It's supposed to be a button of sorts submit
for me to send it, right? Why do you submit the form?
Per the HTML specification, by not specifying anything in the type attribute, the default behavior of the button is
type="submit"
.An approximate translation into Spanish would be:
You can see the documentation in the following links:
http://w3c.github.io/html-reference/button.html
https://www.w3.org/TR/2011/WD-html5-20110525/the-button-element.html#the-button-element