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.

Comments

moshe weitzman’s picture

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.

pete-drupal’s picture

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.

RoboPhred’s picture

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.

karens’s picture

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?

RoboPhred’s picture

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.

moshe weitzman’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

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.

rsantiag’s picture

Version: 6.x-1.x-dev » 6.x-2.0-rc7
Category: bug » feature
Status: Closed (works as designed) » 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.

yched’s picture

Status: Active » Closed (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.