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.
Form Mode Control allow select permissions for all Form Mode for a bundle, even "Default" Form Mode is permitted.
If a user try to use a Form, before "Configure Forms Mode" (admin/structure/display-modes/form/config-form-modes), always use "Default" Form Mode for this form, even if the user roles don't have this permission.
Comment | File | Size | Author |
---|---|---|---|
#13 | form_use_Default_Form_Mode_without_permission-12024268-12.patch | 5.19 KB | bacarndiaye |
Comments
Comment #2
eme CreditAttribution: eme commentedWell in a sense you're right, but issue is that supposing you define default form mode for a user other that the "real" default one, without special permission, he'll be able to do ?display=default and get it even if he shoudn't...
Comment #3
rudam CreditAttribution: rudam commentedSame issue here, the user role only have the permission to use "Generic" form_mode but in node edit He gets the "default" form_mode.
Notice: Undefined index: node.page. in getPermissionByModeAndRole() (line 83 of /var/www/html/drupal/modules/form_mode_control/form_mode_control.module).
Notice: Undefined offset: 2 in controlAccessFormMode() (line 120 of /var/www/html/drupal/modules/form_mode_control/form_mode_control.module).
Comment #4
megan_m CreditAttribution: megan_m commentedSorry, meant to comment in Issue #2737325. I'm wondering if this permissions problem is happening because the config options aren't working (did some digging around in the code but my D8 dev skills aren't that great).
Comment #5
eme CreditAttribution: eme commentedWell, @rudam are your sure you selected in the config page the right form mode.
For now, you always get the default form mode unless you give permission + you define the form mode in the config page.
Comment #6
megan_m CreditAttribution: megan_m commentedI can replicate this too, with the same warnings as @rudam. This was happening when I had set the regular node permissions to create nodes of that content type. I assumed I would need that for users to be able to use the form display modes. To me the expected behaviour would be for the Form Mode control permissions to work with the default node permissions.
Now my problem is that since I've turned that permission off I can't get the Form Mode Control permissions to work ...
Comment #7
psiegel CreditAttribution: psiegel commentedSame problem as #6 for me, whatever permission I set
Comment #8
bander2 CreditAttribution: bander2 as a volunteer commentedAnyone have a workaround for this?
Comment #9
eme CreditAttribution: eme commentedCan you explain me how this is an issue ? By default, if you authorize a role to create, say a article, but do not configure form mode control for it, you should be able to create a new article with the default form mode. Then you can configure if needed which role gets which form mode...
Comment #10
bander2 CreditAttribution: bander2 as a volunteer commentedSorry, I guess I did not understand the issue. For me, users get the default form no matter how I set permissions or defaults. I'll open a separate issue.
Comment #11
bacarndiaye CreditAttribution: bacarndiaye as a volunteer and commentedin debug i have see
$default_id != $form_mode_id
in line 120 form_mode_control is always null.My solution is in function
controlAccessFormMode
before all to test if there arg display.Comment #12
bacarndiaye CreditAttribution: bacarndiaye as a volunteer and commentedComment #13
bacarndiaye CreditAttribution: bacarndiaye as a volunteer and commentedComment #14
woprrr CreditAttribution: woprrr as a volunteer and at NeoLynk commentedYou should use a more OOP approach to make your logic Testable.
Like :
return \Drupal::service('class_resolver')
->getInstanceFromDefinition(EntityTypeInfo::class)
->entityTypeAlter($entity_types);
And you have too many parameters.
try to simply that complexity and have more decoupled approach. That seems not normal to have this needed to add all of these comments blocks.
We can have these information more easily In configFactory. #2838051: Split the default permission for entities by entity type
Comment #15
DakwamineThank you all for your answers. (Hi woprrr)
Regarding the issue, this is because the configuration of the module was not handled properly: old data in the config were not cleared when permissions were unset.
This was fixed in #2844878: Notice: Undefined index: user.user. in getPermissionByModeAndRole() (line 83 of .
Also, I think the process of manually saving the module config could be enhanced by an "automatized" resave upon permission update, at least to remove old entries. A separate issue was created for this task.