API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21Fo...
> Builds and processes a form for a given form ID.
> \Drupal\Core\Form\FormInterface|string $form_id: The value must be one of the following:
> public function buildForm($form_id, FormStateInterface &$form_state) {
But $form_id is NOT a form ID. The form ID is the arbitrary string returned by getFormId() that's used in alter hooks.
The parameter here is either the name of the form class, or an instance of it.
This parameter should be renamed $form_arg to match with:
> public function getForm($form_arg);
> public function getFormId($form_arg, FormStateInterface &$form_state);
Comment | File | Size | Author |
---|---|---|---|
#2 | 3070604-2.patch | 1.75 KB | christinlepson |
Comments
Comment #2
christinlepson CreditAttribution: christinlepson at Mindgrub Technologies commented- Renamed
$form_id
parameter to$form_arg
in Drupal\Core\Form\FormBuilderInterface::buildForm()- Renamed
$form_id
parameter to$form_arg
in Drupal\Core\Form\FormBuilder::buildForm() and used the new parameter to get the form ID.Comment #3
christinlepson CreditAttribution: christinlepson at Mindgrub Technologies commentedComment #4
joachim CreditAttribution: joachim commentedThanks for the patch! LGTM.
Comment #5
jhodgdonThis is confusing, but after carefully reading the code for this function, as well as the function it calls, I think this patch is correct.
As another note, the value that is passed into this function (which is now renamed to $form_arg) is passed into
$this->getFormId()
and that function calls it $form_arg. So this is a good change that will make the function and its documentation less confusing. +1.
Comment #8
webchickAwesome! Thanks a lot for this improvement!
Committed and pushed to 8.8.x and backported to 8.7.x. Thanks!