- ๐บ๐ธUnited States jhedstrom Portland, OR
At a minimum this needs some tests to confirm expected behavior, especially since it is changing the actual access call. This could also potentially be implemented as a separate module, since the access hook needs to only return TRUE from a single hook, not all hooks...
- ๐ธ๐ฐSlovakia coaston
# 19 - the same here. Tested with entity refrence field and enabled 'Create (read-only) own value for field field_list_type' but creator still can change it, even he is not admin.
- ๐ธ๐ฐSlovakia coaston
I can confirm # 16 woks for drupal 9 sites, However does not work for D10 (my current is 10.1.3)
So when I use the same module on D9 site it works as expected (patch #16). However the same does not work on D10. No issues in log, just it is not disabled (greyed out)
Any idea what was changed in D10 in term of permissions ?
- Status changed to Active
about 1 year ago 8:54am 26 September 2023 - ๐ฎ๐ณIndia gaurav_manerkar Vasco Da Gama, Goa
Hook
hook_field_widget_form_alter
is deprecated in Drupal 10
see change record - https://www.drupal.org/node/3180429 โ - Status changed to Needs work
about 1 year ago 3:32pm 10 October 2023 - ๐ฌ๐งUnited Kingdom AaronMcHale Edinburgh, Scotland
In general disabled (or โgreyed outโ) form fields are not good from an accessibility perspective. I would strongly advise against their use.
reroll #13 for Drupal 10 according to #25
Will not work with Drupal 9- Status changed to Needs review
10 months ago 6:15am 14 February 2024 - ๐ฎ๐ณIndia gaurav_manerkar Vasco Da Gama, Goa
We need to support D9 until support is dropped from module itself.
Review MR - https://git.drupalcode.org/project/field_permissions/-/merge_requests/23 - ๐ฎ๐ณIndia gaurav_manerkar Vasco Da Gama, Goa
Covered unit test for read only permissions.
- ๐ธ๐ฐSlovakia coaston
Merge request !23 from #30 created additional issue described here. Rollback was needed.
3440233 ๐ Call to undefined method getEntity() Active
- ๐ธ๐ฐSlovakia coaston
@van.dordafog thank you your patch #28 works fine for D10.2.5.
However as I already mentioned - #31 - Merge request is not working at all.
- ๐ฎ๐นItaly Giuseppe87
On Drupal 10.2.x the MR works fine, but with a standard form. I haven't tried the setup of the related issue.
However looking at the code
$op = $form_state->getFormObject()->getEntity()->isNew() ? 'create' : 'edit';
is both in the MR and in the patch #28, so it's strange that the patch works while the MR doesn't. - Status changed to RTBC
6 months ago 4:47am 24 June 2024 - gaurav gupta Jaipur, Rajasthsan
Hello i have tested the MR23 and it is working fine
Thanks - ๐ฌ๐งUnited Kingdom AaronMcHale Edinburgh, Scotland
Another option for people who need this, could be to use the Readonly Field Widget module: https://www.drupal.org/project/readonly_field_widget โ
The module provides a "readonly" widget, which can be used with a field and allows rendering the field on the form using one of the field formatters. It works even if the user does not have edit permission to the field.
The good thing about that approach is it's much better from an accessibility perspective, the problem with disabled form elements is that often the way they are rendered by browsers it's not always clear to the user that they cannot interact with the element, often disabled elements do not look visually distinct enough from editable elements.
- ๐ธ๐ฐSlovakia coaston
Hi,
Read only field is always read only. But there are a lot of cases i need read only only for some roles, and some of them have to have writte one.
For example project name cannot be changed once created but PM needs to see it so it is clear he is updating the correct one. Or project start date he needs to see it in edit mode but he cannot change it - for this case read only is good enough but sometimes project name has to be changed or other project settings by program lead which has different role.
That's why this feature is awesome and should be implemented to prod version. - ๐ฌ๐งUnited Kingdom AaronMcHale Edinburgh, Scotland
@coaston what I'm trying to do is steer us away from simply making form elements disabled, because, as I noted, that's not great from an accessibility perspective. What I'm saying is that the way the approach taken by the Readonly Field Widget module is good because it doesn't result in "disabled" form elements, it actually just displays the output of the field. Obviously that module is solving a different usecase but the approach taken is a sensible one.
I tested #41. It also makes fields read-only on creating new node form and when editing its own nodes.
I think the field should be "read-only" only when content editor role(example) is editing other people's nodes.
Here's my sample fp table for body field.- ๐ธ๐ฐSlovakia coaston
No it is fine now. If you want edit only yours use own instead.
I'm not sure it's fine, or maybe I've completely misunderstood this approach.
According to the FP table in my previous comment;
Log in as a Content editor and try to create or edit a node, you'll see what I mean.If you want other users to be able to read the field but not edit it, for example, you must select "read only", if you set "original" permissions, the option will disappear and return to its normal state, i.e., you will be able to edit the field again.
In this case, Role 1 has both options to create or edit the normal field, but in role 2, it can only see those fields, it should not be able to create or edit it.
First of all, do we agree on the purpose? If not, if the patch serves a different purpose, then it's my complete misunderstanding of the main idea.
Sorry for this.
But if we agree on the main idea, then excuse me, the patch does not work, it does not serve the idea.
@edde20 I tested your FP table. Result is the same for me.If a content editor can edit his own content field, he can also edit anyone's content field.If he can't edit anyone's content field(read-only), he can't edit his own content field either(read-only). It didn't work for me.- Status changed to Needs review
4 months ago 1:12am 22 August 2024 - ๐ฎ๐ณIndia gaurav_manerkar Vasco Da Gama, Goa
Updated MR with latest code and tests, please review.
https://git.drupalcode.org/project/field_permissions/-/merge_requests/23... - ๐ฎ๐ณIndia gaurav_manerkar Vasco Da Gama, Goa
Updated MR with latest code and tests, please review.
- ๐ง๐ฏBenin delacosta456
hi
the MR 23 worked for me on D10.3.5 + PHP 8.3.
FYI after patchingdrush cr
Thanks
- Status changed to Needs work
about 1 month ago 9:34am 21 November 2024 - ๐ฌ๐งUnited Kingdom scott_euser
The issue summary should use the standard template and needs an update. What the MR does is not really described by the issue so its hard to review it. Seems like its doing a more access control level thing and based on that is disabling a field?
- ๐ฌ๐งUnited Kingdom scott_euser
Curious what happens if you add a new role? They would inherit the permissions from authenticated user at first right?