I need to have two submit buttons that are placed outside my form. Typical solution for two or more submit buttons is either to give each a unique name or same name and a unique value and then check it in $_POST.
Unfortunately, this does not work when I place my buttons outside of form. I've tried to hook up inputs with form's id as "form" attribute and tried to create label with attribute for="input-id" with no luck.
Whichever button I press it is always the first's button name in $_POST.
For example, this is the form:
<form id="my-form" action="some/action">
<input name="title" type="text">
<button hidden type="submit" name="submit-form" id="save" value="save">Save</button>
<button hidden type="submit" name="submit-form" id="save-exit" value="save-exit">Save and Exit</button>
</form>
<label for="save">Save</label>
<label for="save-exit">Save and Exit</label>