Field premissions blocking default value.

RoboPhred - May 20, 2008 - 00:49
Project:Content Construction Kit (CCK)
Version:6.x-2.0-rc7
Component:General
Category:feature request
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

I have a field that is required and has a default value set. Users do not have premission to edit it. Shouldn't the field get the default value in this case? Currently, it is remaining empty.

#1

moshe weitzman - May 20, 2008 - 02:11

what type of field? if a field does not appear on the form, then its requiredness should not be in effect.

please elaborate on how to reproduce this.

#2

pete-drupal - May 20, 2008 - 05:59

I have the same issue in Drupal 5 (tested on a User Reference field).

See #254601: Cannot set and save the value of a read-only User Reference for detailed info. Hope this is still applicable in Drupal 6.

#3

RoboPhred - May 20, 2008 - 15:19

I am making a simple feature request system for my projects. I have a feature request content type, which has a "status" cck field that can be viewed by anyone but only set by those with a certain premission.

The field is a selection list text field, set to required, and has a default value selected.

When a regular user creates a feature request, the field remains empty. I was expecting it to get the default value.

#4

KarenS - May 30, 2008 - 22:26
Status:active» postponed (maintainer needs more info)

The fact that the default value isn't working is a duplicate of http://drupal.org/node/224391. Can't tell if there's some other issue in here or not. Is that the only thing?

#5

RoboPhred - May 31, 2008 - 19:19

I will look into that fix later on, but the issue is:

A content type has a cck field.
The cck field is only accessable to users of a certain role.
Users without the specified role can still create the content type.

Currently, the bug is: when a user creates a content type that contains a cck field they cannot modify, the cck field remains blank.

What I want to happen is: The cck field should recieve the default value when the user does not have premission to edit that cck field.

#6

moshe weitzman - May 31, 2008 - 19:35
Status:postponed (maintainer needs more info)» by design

This is more of a core FAPI issue than a CCK issue. CCK is just setting #access according to whether or not the user can access the widget. If FAPI is choosing not to pass along #default_value, then thats who should be yelled at (maybe - sometimes robophred's behavior doesn't make sense). Here is the relevant line from content_permissions_form_alter():

$form[$field_name]['#access'] = user_access('edit '. $field_name);

Please reopen if CCK should be changed but I suspect either no change or core change is whats needed.

#7

rsantiag - September 29, 2008 - 13:50
Version:6.x-1.x-dev» 6.x-2.0-rc7
Category:bug report» feature request
Status:by design» active

Hi moshe,

I'm having the same issue with defaults values for fields not available in creation time form. I think it isn`t a FAPI issue but a "Default value definition" of CCK. When a read "Default Value" in CCK form content creation, I understand default value when no value was supplied ... I mean, if no value is supplied for this field, the default value will be the value saved to content table.

I think this is an important issue, because it gives to CCK more flexibility.

#8

yched - December 2, 2008 - 17:52
Status:active» duplicate

#334945: Save default value when user has no permission to edit the field is more inline with the current state of the code and has a patch.

 
 

Drupal is a registered trademark of Dries Buytaert.