Form::print_ob_button() reads
$objattr['fieldname'] without checking it is there:
} elseif ($objattr['subtype'] === 'SUBMIT') {
$url = $this->formAction;
$type = $this->formExportType;
$method = $this->formMethod;
$this->SetFormButtonText($objattr['value']);
$this->SetFormSubmit($w, $h, $objattr['fieldname'], ...);
Form.php:532, with the same read at :526 (RESET) and :540 (BUTTON). The neighbouring
optional attributes on the same lines - background-col, border-col, noprint - are all
isset()-guarded, so the shape is deliberate everywhere except this one.
Tag\Input only sets fieldname when the element carries a name, and the HTML spec does
not require one on a submit button: a submit button with no name is not submitted, which is
the ordinary way to write a button that only triggers the form.
Reproducing
$mpdf = new Mpdf();
$mpdf->useActiveForms = true;
$mpdf->WriteHTML('<form><input type="submit" value="Go"></form>');
$mpdf->Output('', 'S');
Warning: Undefined array key "fieldname" in src/Form.php on line 532
Adding name="go" silences it.
Expected: a submit button with no name is given whatever SetFormSubmit() uses for an unnamed
field, the way the optional colours beside it are handled. Observed: a warning under PHP 8, a
notice under PHP 7, and null passed as the field name.
Found while fixing #141; not that issue's shape and deliberately left out of that PR.
Measured on 2982df6, PHP 8.5.4.
Form::print_ob_button()reads$objattr['fieldname']without checking it is there:Form.php:532, with the same read at:526(RESET) and:540(BUTTON). The neighbouringoptional attributes on the same lines -
background-col,border-col,noprint- are allisset()-guarded, so the shape is deliberate everywhere except this one.Tag\Inputonly setsfieldnamewhen the element carries aname, and the HTML spec doesnot require one on a submit button: a submit button with no name is not submitted, which is
the ordinary way to write a button that only triggers the form.
Reproducing
Adding
name="go"silences it.Expected: a submit button with no name is given whatever
SetFormSubmit()uses for an unnamedfield, the way the optional colours beside it are handled. Observed: a warning under PHP 8, a
notice under PHP 7, and
nullpassed as the field name.Found while fixing #141; not that issue's shape and deliberately left out of that PR.
Measured on
2982df6, PHP 8.5.4.