Knowing this helped me fix a bug. It'd be incredibly helpful to document this.
- πΊπΈUnited States paulmckibben Atlanta, GA
This was a root cause for an ajax issue I was experiencing, due to two different forms appearing on the same page. On one of the forms, ajax submit failed to get a callback method because the formState->getTriggeringElement() returned NULL.
Once I assigned a unique #name to the submit button for the form that was failing to submit using ajax, the problem was fixed.
Before:
$form['filter-container']['top-row']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Submit'), '#id' => 'license-filter-submit', '#ajax' => [ 'callback' => '::ajaxUpdateLicenseResults', 'wrapper' => 'license-results-container', 'progress' => [ 'type' => 'fullscreen', ], ], ];
After:
$form['filter-container']['top-row']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Submit'), '#id' => 'license-filter-submit', '#name' => 'license-filter-submit', '#ajax' => [ 'callback' => '::ajaxUpdateLicenseResults', 'wrapper' => 'license-results-container', 'progress' => [ 'type' => 'fullscreen', ], ], ];
Adding a unique '#name' fixed the triggeringElement issue.
Adding this here in hopes that anyone else experiencing this particular use case will find it.
The issue summary was updated/improved in #13 but the tag wasn't removed after.