- Issue created by @mlncn
- ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
The reason this is getting applied when it is not expected is because the base form is a node form and so the condition
$form_state->getBuildInfo()['base_form_id'] ?? NULL) === 'node_form'
(line 375 of src/GinContentFormHelper.php) is evaluating to true.The reason we cannot opt out of it is because the
$form_ids_to_ignore
(line 335 of src/GinContentFormHelper.php) is hard-coded, with no alter hook.Given this is a pretty custom one-off case i'm not sure we should look more into automatically ensuring this does not apply when it might break things, but it seems that might be possible (check for edit_actions somewhere)?
- ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
Ah but excluding the form means the buttons do not show up at all.
Seems that the modifying/placing and the removing should be handled in one spot.
- ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
Changing this to a feature request, since as covered above we can avoid this error if we can exclude custom (but content-extending) forms from Gin's enhancement of content forms.
Note that the ability to exclude by route will not help because the check for base_form_id, while mixed in with the check for routes, is independent and if it returns true the enhancements get applied.
Also, even where restricting by route can work, the route as in the example is for all entities of a type, so for all nodes, not by content type, so in many cases definitely too broad.
Allowing the
$form_ids_to_ignore
variable to be modified by third-parties (the same way routes already can be, in the same method) seems a very straightforward improvement.Merge request forthcoming.
- Merge request !532Issue #3488050 by mlncn: Allow form IDs to be ignored from Gin content form enhancements โ (Open) created by mlncn
- ๐ฉ๐ชGermany jurgenhaas Gottmadingen
@mlncn We're currently working on ๐ Improve sticky actions implementation Active and with the latest version of the MR!536 the javascript error in the IS should be gone. Would you mind giving that a try and letting us know if that's true?
If not, please help us to find out what's still wrong with that, as we need to iron that out before we start looking into
form_ids_to_ignore
androute_names
in the\Drupal\gin\GinContentFormHelper::isContentForm
. - ๐บ๐ธUnited States mlncn Minneapolis, MN, USA
Congratualations on figuring #3489493 out and apologies for not helping there; but this should be unblocked now.
- Status changed to Needs review
17 days ago 3:32pm 16 May 2025 - ๐บ๐ธUnited States bjcooper Nebraska, USA
I've run into a related issue here, where you can't actually disable sticky action buttons on content forms.
The
GinContentFormHelper->formAlter()
method does actually check if the current form ID should have sticky action buttons or not usingGinContentFormHelper->stickyActionButtons()
โwhich invokes alter hooks so you can ignore form ids viahook_gin_ignore_sticky_form_actions_alter
. This I've done, and I can see that$sticky_action_buttons
has been set toFALSE
for the form I'm trying to skip sticky action buttons on.However,
formAlter()
immediately ignores that flag for content forms, renderinghook_gin_ignore_sticky_form_actions_alter
completely useless for content forms:public function formAlter(array &$form, FormStateInterface $form_state, $form_id) { //... // Save form types and behaviors. $use_sticky_action_buttons = $this->stickyActionButtons($form, $form_state, $form_id); $is_content_form = $this->isContentForm($form, $form_state, $form_id); // Sticky action buttons. if (($use_sticky_action_buttons || $is_content_form) && isset($form['actions'])) { // Add sticky action button behavior...
This seems like an oversight in the logic, since you can never disable sticky action buttons on content forms this way, in effect, ignoring
gin_ignore_sticky_form_actions
. - ๐บ๐ธUnited States bjcooper Nebraska, USA
At any rate, adding similar ignore form id alter hooks to
isContentForm()
like @mlcn mentioned would certainly help. Ideally, though, thestickyActionButtons()
method would actually control sticky actions behavior (it could default to true for content forms by callingisContentForm()
itself when the setting is enabled), and the remaining alterations specific to content forms would only be controlled byisContentForm()
and its new alter hooks. - ๐บ๐ธUnited States bjcooper Nebraska, USA
Related issue: https://www.drupal.org/project/gin/issues/3406878 โจ Support for the Mercury Editor module Active