Empty set of block roles?

bhuga - April 15, 2009 - 22:45
Project:Patterns
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Is there a way to create an empty list in a YAML pattern to uncheck all options in a list?

I'm trying to update a block, and part of that update is to ensure that no roles are selected for the block (i.e. all roles).

The actions portion is this:
actions:
# account settings button
- tag: block
id: spawar_support-2
theme: felice
visibility: 1
pages:
- node/*

If I have no roles: field, it leave the roles unchanged. If I declare it in any way, it seems to find it invalid unless I actually specify a role.

Looking at the code, I don't think that this is workable without a fix. I can provide that, but just checking that I'm not missing something.

#1

bhuga - April 16, 2009 - 23:26
Status:active» needs review

This patch allows the use of 'roles: none' to specify that roles should be explicitly cleared.

AttachmentSize
patterns-block-no-roles.patch 1.1 KB

#2

sarvab - April 17, 2009 - 07:14

Hi Bhuga, thanks for the patch!

That looks like it should do the trick, but just in case, there are some recent commits I made that have direct relavence to all checkboxes/radios/selects that may make just specifying an empty roles: element possible.

If that works we can go that route but if not lets commit this patch.

#3

sarvab - April 17, 2009 - 12:09

Some commits were just made that should make this and similar areas everywhere else work much better. Now you can decide at any place (not just blocks) where you are setting values for checkboxes/radios/selects wether you want to overwrite or update the values

The default in most cases is to update the values, so as in the case here, if you have anonymous already selected for a block and do

      roles: authenticated

It will keep anonymous selected and add the authenticated role as well.

To overwrite, using the roles here as an example you can do one of the following to make the end result exactly what you specify here.

      roles:
        _overwrite_: anonymous

      roles:
        _overwrite_:
          - authenticated
          - administrator

      roles:

I would love to hear if this works out for you or any thoughts you may have on the matter!

#4

bhuga - April 21, 2009 - 23:14

Sarva,

This is works great for me. Thanks for your significantly better, more generic fix :)

Ben

#5

sarvab - April 21, 2009 - 23:43
Status:needs review» fixed

Great, glad to hear its working for you alright!

#6

System Message - May 5, 2009 - 23:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.