Closed (duplicate)
Project:
Profile permission
Version:
6.x-1.1
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
9 Feb 2010 at 12:17 UTC
Updated:
29 Oct 2010 at 19:15 UTC
Hello Team! I've noticed that if user hasn't permission to edit a field the value of this field will be reset on submit. For example administrator add something to this field. However normal user without permission to edit this field go to edit form and save it. This will reset protected field value.
This is caused by unset($form[$category][$key]) function because the field is not visible but profile module will insert empty value for this field. A possible solution of this is:
//unset($form[$category][$key]);
$form[$category][$key]['#type'] = 'value';
$form[$category][$key]['#value'] = isset($form[$category][$key]['#default_value']) ? $form[$category][$key]['#default_value'] : '';
Comments
Comment #1
sampeckham commentedHaving the exact same problem. Each time a user edits available fields to them the restricted fields (unseen by the user) are wiped.
Will try the solution - is this editing the .module file?
Sam
Comment #2
CardinalFang commentedThanks for the solution, it seems to work for me.
Comment #3
ilo commentedI'd say, this approach solves the problem, but still hides the field even if user is able to see it with edit permission, setting to disabled or as 'markup' when user has view permissions would be prefered.
Closing because of duplicate with a patch to solve and other related issues at once: #957188: Fixing permissions, reset and validation errors on protected fields