Hi,
I don't want my members to be able to change any settings in the "gallery settings" fieldset.
I just want to be able to set the defaults and hide the fieldset altogether.
Also, the same with the "blocks" tab at the bottom of the edit/create node page. I would just like to hide this altogether.
Is this possible? I have played around with css, unlcoked all the fields in the db etc but still cannot hide the actual fieldset. All fields within the fieldset disappear but the actual wrapper stays there at full height.
By the by, this should be simpler than hacking the SQL to unlock the fields and set defaults/hide from users.
Any ideas on how to hide?
Thanks.
Shaun
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedCSS is OK for hiding something from easy view, but not for actually preventing people from changing it, so it's probably not the best solution anyway.
Have you tried writing a small bit of custom code that uses hook_form_alter() to set
'#access' => FALSE
on the fieldset?Comment #2
dRaz CreditAttribution: dRaz commentedDavid,
Thanks for the reply.
I did want to try that solution but I could not find the right .inc file to insert the code....it all seems very "all over the place"? Or maybe I can't see the forest for the trees....
Comment #3
bschilt CreditAttribution: bschilt commentedI'm dealing with the same issue. I want to set a bunch of default values for the settings, then hide the fieldset. Like @David_Rothstein suggested I used a hook_form_FORM_ID_alter() to set the defaults that I wanted, but I was never able to find the fieldset element in the $form variable, so I'm hiding the fieldset via css. Does anybody know how the fieldset is added to the $form object?
@dRaz, you'll need to put that custom code in a custom module, here is the code I used to set the defaults.
Comment #4
dRaz CreditAttribution: dRaz commentedThanks bschilt,
Hopefully with a few heads working on this we can get this issue solved - seems weird that this cannot be done out of the box.
Comment #5
Moloc CreditAttribution: Moloc commentedJust as a additional information to comment #3.
The Media Gallery module uses the same hook, where media gallery adds the block and the fieldset. The media gallery hook implementation also moves all media gallery settings to the fieldset (from $form['media_gallery_rows'] to $form['settings_wrapper']['media_gallery_rows'] and so on.).
So, if your code in comment #3 works, then your hook is executed before the media gallery hook and all your changes are also moved.
So the question is, how do you know, if your hook is executed before the media_gallery hook or after? The answer is the module name (as i read somewhere; i also tested it).
If your module-name is alphabetical lower than "media_gallery" (for example "a_module", "b_module",...) then your hook is executed before the media_gallery hook, and therefore you can not see the fieldset and block settings.
If your module-name is alphabetical greater than "media_gallery" (for example "x_module", "z_module",...) then your hook is executed after the media_gallery hook, and therefore you can see the fieldset and block settings and modify them.
I hope that helps.
Comment #6
bschilt CreditAttribution: bschilt commented@Moloc, you're right about the module weight being the issue here. My module started with an 'a' so it was being executed before media_gallery. I can't believe I blanked on this, its a common issue I run into a lot. anyway...
Add the following lines to the alter function I posted above to remove the settings and block fieldsets.
Comment #7
dRaz CreditAttribution: dRaz commentedFantastic work bschilt :) +10
Comment #8
David_Rothstein CreditAttribution: David_Rothstein commentedAs an alternative to changing the module name, you can instead change the module weight in the {system} table to make it run later, or (the best option) you can use hook_module_implements_alter(). That way you can target the specific hook you want (in this case 'form_alter') to run in the order you want it to.
Although the latter one will definitely be the best option soon, due to a bug it may not always work reliably at the moment though (see #765860: drupal_alter() fails to order modules correctly in some cases).
Comment #9
bschilt CreditAttribution: bschilt commentedAfter making sure your module's form alter function is called after media gallery use the following code to set the default settings and hide the fieldset:
We no longer need to hide each field now that we're hiding the fieldset.
Comment #10
totap CreditAttribution: totap commentedStupid question, but how and where implement this code to get rid of unwanted fieldsets?
Comment #11
dRaz CreditAttribution: dRaz commentedHi to tap,
You need to create a new module yourself to use this code.
Create 2 files:
media_gallery_settings_hide.INFO
media_gallery_settings_hide.MODULE
Place these into a folder called media_gallery_settings_hide in your modules folder.
INFO file should contain:
name = media_gallery_settings_hide
description = Hide the settings in creating a gallery
core = 7.x
files[] = media_gallery_settings_hide.module
MODULE file should contain the code written in above post(s).
Upload these to your site's module folder and enable.
Hope this helped.
Comment #12
totap CreditAttribution: totap commentedThank you dRaz very much:)
The code of bschilt #3 and #9 didn't worked for me, but now I know how to make modules :)
Comment #13
jkenters CreditAttribution: jkenters commentedI just started using Drupal, so I'm very sorry if the code below is the worst you have seen in years :-)
I could not get the code above to disable all I wanted. My module was named 'zzzcustom' with a high weight, so I thought zzzcustom_form_media_gallery_node_form_alter would be the last thing changing the form/tabs. But xdebug showed me this was not the case: the media_gallery hook was run after it because they used hook_module_implements_alter() to change the order. So, I did the same thing in my own module to get the desired effect:
Now all the fields/tabs I don't want are hidden to the user. Hope this helps someone.
Comment #14
ivnish CreditAttribution: ivnish commented