Project:Patterns
Version:6.x-1.x-dev
Component:Documentation
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

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.

Comments

#1

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

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

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

Sarva,

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

Ben

#5

Status:needs review» fixed

Great, glad to hear its working for you alright!

#6

Status:fixed» closed (fixed)

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

#7

Component:Code» Documentation
Status:closed (fixed)» needs work

Sorry for reopening this, I'm just marking it for documentation as I don't believe this was added to the d.o documentation.