Form data are not sent with a button instead of an input

Hello,

Following the Email contact form recipe, data are never sent if i use a <button type="submit"> instead of the <input type="submit">.
Tried to dump get('submit') and it return nothing.

Is it a bug or something I miss?
Thanks!

You have to give your button a name attribute, just like for the input. The parameter you pass to get() is not the type, but the name of the element. Otherwise you could only ever have one element of a type.

Hi Sonja,

Sorry I have reduced the code here on my example, but my button really have a name attribute.
<button type="submit" name="submit">Send</button>.
This is also the only one on my form to get a submit type. I’ve just replaced the input by the button.

I’m running on Kirby 3.4.4.

Hm, that’s weird. What do you get if you dump( $_POST)? I’m pretty sure this has nothing to do with Kirby, after all sending a form is just a HTML thingy.

Here the dump($_POST) results.

input:

Array
(
    [honeypot] => 
    [csrf] => d486191dd9c8fac3677df2fa5cb6282be9d1fcb517d3064228b29c2cf698c03f
    [email] => contact@example.net
    [text] => Hello Kirby.
    [submit] => Send
)

button:

Array
(
    [honeypot] => 
    [csrf] => d486191dd9c8fac3677df2fa5cb6282be9d1fcb517d3064228b29c2cf698c03f
    [email] => contact@example.net
    [text] => Hello Kirby.
    [submit] => 
)

Here the submit is empty.

I tried both on my portfolio and on a client site, the form does not work with a button and work well with the input :exploding_head:.

If you want submit to have a value, you also have to give your button a value. Looks like get('submit') only returns true if there is a value.

Thanks you for find it out!

I should stop coding late at night.