Problem/Motivation
A PHP notice is thrown when a new Invite type is created:
Notice: Trying to access array offset on value of type bool in Drupal\invite\Form\InviteTypeForm->form() (line 132 of modules/contrib/invite/src/Form/InviteTypeForm.php).
Drupal\invite\Form\InviteTypeForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 531)
...
https://www.drupal.org/files/issues/2022-04-18/add-invite-notice.png
Steps to reproduce
- Go to the page: Administration > Structure > Invite type > Add Invite type
/admin/structure/invite_type/add
- Check the Drupal error log. If you have errors set to display you should also see an error message on the screen.
Proposed resolution
The Notice is caused by this statement:
'#default_value' => $data['target_role'],
$data is not fully populated with values when a new invite_type entity is created.
The most straightforward fix is <?php '#default_value' => $data['target_role'] ?? '',
A patch to follow.
Comments
Comment #2
dale42The patch.
Comment #3
renatog commentedTotally agree. Really makes sense
Comment #6
renatog commentedMoved to the dev branches 8.x-1.x and 2.0.x
Thank you so much for your great job @dale42
I'm testing the Hook Mail as well.