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
Comment #1
bhuga commentedThis patch allows the use of 'roles: none' to specify that roles should be explicitly cleared.
Comment #2
sarvab commentedHi 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.
Comment #3
sarvab commentedSome 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
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.
I would love to hear if this works out for you or any thoughts you may have on the matter!
Comment #4
bhuga commentedSarva,
This is works great for me. Thanks for your significantly better, more generic fix :)
Ben
Comment #5
sarvab commentedGreat, glad to hear its working for you alright!
Comment #7
ChrisBryant commentedSorry for reopening this, I'm just marking it for documentation as I don't believe this was added to the d.o documentation.