Skip to content
Snippets Groups Projects

Make sure the flag form element doesn't appear on non-edit forms

1 file
+ 3
4
Compare changes
  • Side-by-side
  • Inline
+ 3
4
@@ -72,10 +72,9 @@ function flag_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Check the first flag and return early if the form isn't considered to be
// an edit form.
if (!empty($flags) && isset($flags[0]) && $flags[0] instanceof FlagInterface) {
/** @var \Drupal\flag\Plugin\Flag\EntityFlagType $flag_type */
$flag_type = $flags[0]->getFlagTypePlugin();
if (!$flag_type->isAddEditForm($object->getOperation())) {
$first_flag = reset($flags);
if ($first_flag instanceof FlagInterface) {
if (!$first_flag->getFlagTypePlugin()->isAddEditForm($object->getOperation())) {
return;
}
}
Loading