Problem/Motivation

The following problem exists:
- Create a Role Reference field for a Content type. In the Field settings, make a selection of roles;
- Add content;
- Add a new role;
- Re-visit the Field settings. Try to add the new Role to the selection. It is not possible. The field with role-selection is greyed out.

Proposed resolution

Comment #1 has a solution, which is explicitely shown in #6.

Original report by devenderdagar

Thanks a lot for such a nice module. I was just exploring this module and found that if some more roles are added at later stage after creating some contents where Role reference is used as cck, the module doesnt allow to check new Roles in the content type settings. Any idea ?

Regards, Devender

Comments

oda’s picture

This field update limitation can be really annoying. Usually you can ignore the message and update the field, but this is not the case. A simple workaround is to edit rolereference.module and comment line 57.

johnv’s picture

StatusFileSize
new870 bytes

EDIT: this makes no sence.
devenderdagar, the status of your post was misleading: 'needs review' implies an attached patch.

Well, now it has... ;-)
If you do not check any of the roles in the field settings, they will ALL appear in the node edit/add form.
A newly created role will also appear.

johnv’s picture

Priority: Major » Normal
Status: Needs review » Closed (duplicate)

OTOH, the same patch (but better) can be found here: #1280532: Allow any role to be referenced if none are explicitly selected.
marking this as a duplicate.

oda’s picture

Category: support » feature
Status: Closed (duplicate) » Active

I do not consider this as duplicate. It's a different request. We are talking about the possibility to change the field configs after its creation.

johnv’s picture

EDIT: this makes no sence.
Then I do not understand what you mean. Maybe you need to run the following page after changing the settings: /admin/report/status/rebuild (For Rebuild permissions)
If so, the module should call variable_set('node_access_needs_rebuild', TRUE); after changing a role field.

johnv’s picture

Version: 7.x-1.0 » 7.x-1.1
Category: Feature request » Bug report
Issue summary: View changes
Status: Active » Needs review

I came across this issue. My remarks earlier are *** . I totally misunderstood the OP.
The proposed solution in #1 should do the trick. Below the explicit code.
(Setting this 1-line-patch to Needs Review, although there is no real patch-file.)

/**
 * Implements hook_field_settings_form().
 */
function rolereference_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];

  $form = array();
  $role_options = array_map('check_plain', user_roles());
  $form['referenceable_roles'] = array(
    '#type'          => 'checkboxes',
    '#title'         => t('Roles that can be referenced'),
    '#description'   => t('Select roles that may be referenced by this field. All roles will be available if none are checked.'),
    '#multiple'      => TRUE,
    '#default_value' => is_array($settings['referenceable_roles']) ? $settings['referenceable_roles'] : array(),
    '#options'       => $role_options,
-   '#disabled'      => $has_data,     // <== Remove this line.
  );
  return $form;
}
johnv’s picture

Issue summary: View changes
johnv’s picture

Title: Adding new roles at later stage » Cannot add new roles at later stage, "Because the field already has data, some settings can no longer be changed."
johnv’s picture

Issue summary: View changes
StatusFileSize
new481 bytes

A proper patch.

greg__’s picture

#9 works for me

mykhailo.levchenko’s picture

Tested this. Works for me

alex liannoy’s picture

Status: Needs review » Reviewed & tested by the community

  • deekayen committed 9a77b74 on 7.x-1.x authored by johnv
    Issue #1347616 by johnv: Cannot add new roles at later stage,  "Because...

deekayen credited deekayen.

deekayen’s picture

Status: Reviewed & tested by the community » Fixed
deekayen’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.