Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Because it does not return the status of the saved key.
Comment | File | Size | Author |
---|---|---|---|
#4 | key-entity_forms_updates-3048562-4.patch | 3.24 KB | AaronBauman |
| |||
#2 | parent-3048562-2.patch | 1.52 KB | Sergiu Stici |
|
Comments
Comment #2
Sergiu Stici CreditAttribution: Sergiu Stici at FFW commentedHere is the patch, please review.
Comment #3
jcnventura CreditAttribution: jcnventura commentedI'm pretty sure it still doesn't return the status. I think the proposed patch is not improving anything, as it saves the entity twice.
EntityForm::save(), which this class extends is defined as:
Instead of just calling
parent::save($form, $form_state);
at the beginning (which saves the entity for the first time), delete all the lines before and inside the try (which are saving the entity for the second time). Replace the current try body with$status = parent::save($form, $form_state);
. Oh, and then add a return $status at the end of the call, of course.I haven't checked the code for the other two functions where the patch is calling the base class, but it is very likely that similar changes have to be made.
Comment #4
AaronBaumanHere's a reworking of the patch:
1) removes the
submitForm()
method fromKeyConfigOverrideDeleteForm
in favor ofgetDeletionMessage()
2) implements
getDeletionMessage()
inKeyDeleteForm
3) update
KeyFormBase::save()
to remove the try/catch, sinceEntityFormInterface
does not accommodate returningNULL
.also replace
drupal_set_message()
withmessenger()
FWIW, many core implementations return void in violation of
EntityFormInterface
, and also do not perform any exception handling:\Drupal\node\NodeForm::save
,\Drupal\menu_ui\MenuForm::save
,\Drupal\media\MediaTypeForm::save
,\Drupal\workflows\Form\WorkflowEditForm::save
, etc.Comment #5
jcnventura CreditAttribution: jcnventura commentedComment #6
rlhawkThis is terrific. Thanks, all.
Comment #8
rlhawk