Closed (outdated)
Project:
Field Permissions
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 Apr 2012 at 13:51 UTC
Updated:
6 Feb 2025 at 20:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rbennata commentedI need this functionality too.
Comment #2
allio_froggio commentedThe current implementation is confusing, as you can't actually edit the setting but it appears that you can (still see the drop down, but it doesn't save). Showing just a greyed out box would be awesome!
Comment #3
joachim commented+1 for this.
Though AFAIK making a form element read-only is a bit flaky in FormAPI -- setting #disabled = TRUE can be worked around with Javascript, so the module would have to make sure that a changed value is not accepted.
Comment #4
honza pobořil commentedSorry, my mistake. Correct attribute is #disabled
Comment #5
joachim commented> Though AFAIK making a form element read-only is a bit flaky in FormAPI -- setting #disabled = TRUE can be worked around with Javascript, so the module would have to make sure that a changed value is not accepted.
Turns out I'm wrong about this :)
Comment #6
fraweg commented+1
I need this feature too..
Have someone sove this issue with a workaround?
Best regards
Frank
Comment #7
fraweg commentedI hope this thread is not dead ;-) I really want this feature...
Best regards
Frank
Edit:
When I read this:
#######################
Maintainers for Field Permissions
Rob Loach - 21 commits
last: 23 weeks ago, first: 1 year ago
markus_petrux - 28 commits
last: 2 years ago, first: 2 years ago
#######################
I thing there is no activity in this project... :-(
Comment #8
jelo commentedI need the same feature as well. Users should be able to view the value for specific fields on the user edit form (e.g. with a greyed out field), even though they might not have the permission to edit the value.
Comment #9
sw3b commented+1 on this feature ! Anyone find a workaround for this request ?!?
Comment #10
fraweg commentedI need a work arround too :-( !
Comment #11
fraweg commentedMaybe its a good idea to let the user choose in witch way he want to use it. Maybe someone want to have it hide and someone like it greyed out.
Best regards
Frank
Comment #12
jelo commentedThat would be ideal, e.g. a configuration option in the settings to decide if read-only fields should not be shown on the edit form or be shown as greyed out. In such a configuration screen, it would be great if we could enter text as a description/notification to the user as well why the field is greyed out. In my use case, we would have to specify that the data is coming from another system and that the user has to change it there to update the value... I would be fine with a global setting for all fields, but maybe other users would need a more granular approach, e.g. configuration of visibility and notification per field.
Comment #13
jelo commentedHas anyone found a solution for this?
Comment #14
fraweg commentedHello,
no, not really.. :-(
Best regards
Frank
Comment #15
mordonez commentedHi,
I did a solution for this problem, basically I created a new permission "Edit (read-only) anyone's value". If one role has this permission, the user with this role can edit but can't change the value of the field.
I used the hook
hook_field_widget_form_alterfor access the field's attributes and change the disabled widget's attribute if user has this new permission and not the permission "Edit anyone's value".This hook was introduced in Drupal 7.8 but I hope this helps.
Comment #16
mordonez commentedI improved the solution using
field_permissions_field_attach_forminsteadhook_field_widget_form_alterComment #18
mordonez commentedComment #19
fraweg commentedHello,
Did the patch #18 respect this?
Best regards
Frank
Comment #20
mordonez commentedYes
Comment #21
fraweg commentedHello,
at first..many thanks for your work in this issue!
For me the test with patch #18 failed. I have no error messages but when I activate the new field I can edit and in this case change the value of this field. Nothing is greyed out. In the screenshot you can see my setting...
Do I something wrong?
Best regards
Frank
Comment #22
mordonez commentedHi fraweg,
thanks for your feedback. I tried with a fresh install and it works. Did you tried to rebuild permissions at
admin/reports/status/rebuild?Comment #23
fraweg commentedHello,
Thanks for that tip...! Now it works ! Thanks so much for your support.
Is there a way to make it also work with fields wich have a selectbox? For example the Birthday module. I think no one should be able to change his birthday ;-)
Best regards
Frank
Comment #24
mordonez commentedIt works with core fields, entity reference, date... all fields that correctly implements field API. But It seems the Birthday module not the case.
Sorry.
Comment #25
attiks commentedIt works perfectly
Comment #26
JThan commentedAs writing this, the solution popped up: Clear the cache also. That Drupal cache is just too good. So, yeahh, works, pleas include in the module.
____________________________________________
I tried the today. the read-only option is showing, but I can still edit the field. It is a new installation with some other Modules already installed. The field can be hidden, but greying it out with your patch did not work.
I did rebuild the permisions.
___________________________________________
Comment #27
dsrikanth commentedThis is great! Thank you so much for the patch!
I tested it out and it works great. However it isn't working as expected with Field Collections. The fields inside the field collection shows up in the editable format. I am guessing its because filed collection doesn't store it as $form_state['field'][$field_name]
I encountered this problem in office hours module and wrote a patch
http://drupal.org/node/1689296#comment-6925544
http://drupal.org/node/1689296#comment-6956622
Similar approach might help fix this for fields inside Field Collections
Comment #28
kaizerking commented@dsrikanth could you please provide patch supporting field collection i am looking for this
Comment #29
dsrikanth commented@kaizerking - sorry, I did give it a shot but couldn't get it to work. I will post an update if I find a way to get this done. For now, I am fixing my issue by hardcoding my field collection fields name and disabling them inside this module.
Comment #30
elvis2 commented@mordonez Thanks for the patch. I was able to successfully patch my version of field_permissions 7.x-1.x-dev (from 2012-01-11) with #18.
I have a question about the language. Instead of using "edit (read-only)" as the label would "view (read only)" make more sense? After patching then editing a field I was a little confused by the word "edit". Maybe you can shed some light on that.
Thanks!
Comment #31
rexington commentedmordonez, thank you for that patch! #18 worked perfectly for me.
Comment #32
mpark commentedThis patch doesnt working, I dont know, but is this line correct?
function field_permissions_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) {global $user;
list($id,,$bundle) = entity_extract_ids($entity_type, $entity);
Comment #33
katannshaw commented@dsrikanth: Has there been any update on creating a patch to get this to work with field collection? As with you and kaizerking, this patch works great for me on regular fields but not on field collection fields, as they're still editable. Also, could you post your code for hardcoding field collection fields into read only fields? I'm new to PHP, so that would be a great temporary fix. Thanks.By George I believe I've (partially) got it. What didn't work was to go into the field collections properties at http://mysite/admin/structure/field-collections and attempt to customize the permissions there.
What did work was for me to go to the *main field settings page for my content type* at admin/structure/types/manage/[content-type-name]/fields/[field-name], changing the Field visibility and permissions to Custom permissions, and selecting the "read only" option from there. Once I did that, it worked for the field collection fields as well.
I still cannot get it to accept one field as read-only within a field collection though. Hopefully a new patch/solution comes out for that.
Hope it helps. Great patch!
Comment #34
agerson commented+1 for this functionality. Can we get it added to the dev branch?
Comment #35
dema501 commented#18 works for me
Comment #36
rterman commentedI tried on my own site as well as a blank site and it didn't work. But when I removed the following lines in the patch in #18, it worked. Why does the entity have to be new?
Comment #37
liliplanet commentedThank you for this module! The problem I'm having is that when I select 'Authenticated' as want only Premium and Platinum to be able to add and edit, the whole row gets selected and unable to deselect Premium and Platinum. Any guidance would be most appreciated :)
Comment #38
anrikun commentedYou may try the Field Readonly module.
Comment #39
duckydan commented18: field_permissions_edit_field_read_only_1547172_17.patch queued for re-testing.
Comment #40
Leo Jiménez commentedNot working for me patch on #18. I clear cache and rebuild permissions. Module Field Readonly on #38 work correctly.
Thanks
Comment #41
gocaps commentedI had problems with patch #18. I solved the issue by implementing hook_form_alter in my template.php file:
And then added some CSS to highlight the disabled fields:
Comment #42
romansta commentedI had also problems with patch #18 and tried the readonly-module too - without success. #41 did it for me.
Comment #43
liquidcms commentedtried patch in #18 - seems to work as expected. seems like an obvious addition to this module; would be good if we could get it committed.
Comment #44
loparr commented@liquidcms what version did you use for patching? dev or 7.x-1.0-beta2
thank you
Comment #45
liquidcms commented7.x-1.0-beta2
Comment #46
marcus_clements commentedThanks for fixing this.
The patch works well in 7.x-1.0-beta2 and is a requirement for my project so I'd like to see this committed.
Comment #47
mariacha1 commentedI'd prefer to do this with a hook once https://www.drupal.org/node/1448154 is committed.
Comment #48
zekvyrin commentedI see the related patch is committed.. so I'm updating the issue to needs work, for someone to implement it with the hook probably
Comment #49
roflcopterDorrie commentedWhilst waiting for some good citizen to implement with the hook, I have updated so it applies to dev
Comment #50
thulenb commentedIs it possible to committ this soon?
Comment #51
nwom commented#49 worked great. Thank you! Any chance this can get committed?
Comment #52
nwom commentedActually just ran into a small issue. When setting up Field Permissions to hide an entity reference field (for specific roles) that has add/edit buttons via Entity Connect, it works great. Both the field and the buttons are hidden.
However, when using this patch and making the field instead Read Only, the field shows up as read only (which is great), but it allows you to still use the add/edit buttons (not intended). I'm guessing this problem can occur with other modules as well.
Comment #53
w01f commentedIs there a D8 version of this patch/feature? I think a toggle/selector to hide/read-only would be great, as I have several fields I'd like to remain hidden, but a few that would be best for read-only/greyed-out.
Comment #54
mrpauldriver commentedI too would like to see similar functionality for the D8 version and have opened separate feature request.
Provide a form display formatter for greying-out a field or hiding it completely
Comment #55
bluegeek9 commentedField Permissions does not support Drupal 7.