By jeeves on
By default, the "File attachments" fieldset loads up collapsed when editing or creating a node. This creates a problem for site users because they don't notice where they are supposed to upload files.
Is there anyway I can just have the File attachment fieldset just load up expanded, so it's easy to spot?
Comments
Override theme_fieldset
It's not trivial, but the most straightforward way would be to include in your theme an override of the theme_fieldset function
http://api.drupal.org/api/function/theme_fieldset
But I might be over-thinking this one.
[You could also add a touch of jQuery to the page, so that the fieldset opens at load.]
Something like (this is UNTESTED)
http://CrookedNumber.com
Looks good
quick follow up. I just tested this on a (local) drupal test site. Seems to work.
Anyone else, feel free to chime in if there's an even easier solution.
http://CrookedNumber.com
What about
What about this:
Where are you placing that
Where are you placing that line of code?
http://CrookedNumber.com
In any hook_form_alter
In any hook_form_alter implementation at your modules, you could alter whatever form you want (i.e. [nodetype]_node_form). You'll be altering the behaviuor of attachment fieldset to be always expanded (in other words never collapsed) by this code snippet:-
I hope that helps
True
Yeah, this looks good to me. I was assuming that Jeeves wanted every node form to always behave this way and thus wanted to do this on the theme level, rather than build a module just to do that. But re-reading his first post, that's not entirely clear.
Jeeves? Any update on this?
http://CrookedNumber.com
looks but but doesn't work for me
hi!
Seems to be a nice improvement indeed. I applied it on a Drupal 6 site i am building, but doesn't seem to work. It is supposed to have effect at node creation time in that form as well, isn't it? Here's the code that doesn't work for me, it's in a module file which is enabled on the site, and there are no other custom modules altering forms:
Get rid of the return
Get rid of the return statement. You make changes to the form passed by reference, so you don't need to return anything...
Working
Thanks.This code will work.
Better in template.php
You can force it in template.php for each theme with this code if you know the form_id
function phptemplate_[FORM_ID]_form($form){
$form['attachments']['#collapsible'] = false;
return drupal_render($form);
}
Good luck ;-)
----------------------
Freelance
http://programadorphp.es
jQuery code works perfectly!
Just copied and pasted your code in my theme's template file, changed the theme name to my own, and VOILA! It works like a charm. Just wanted to send a quick thanks.
Hillary
Add this to your
Add this to your template.php, it will open the file attachments fieldset on all node forms:
Not working for me! Help!
I am trying to do exactly what you described. I have used the code provided by aschiwi and many different variations of the code provided by vigoncas. However it's not working for me.
I have Drupal 6.13 and am using garland. I have pasted the code in template.php in themes/garland. I have tried function names with prefix phptemplate (similar to the other functions that are in template.php for garland) and prefix garland. My cache is cleared and turned off. Can anyone who has gotten this to work post more details? Or does anyone know what I might be missing?
Thanks!
Some additional information: the form_id is 'contributed_node_form'; I have tried function names in any combination of
garland_ or phptemplate_
plus
node_form
contributed_node_form
contributed
If there is a syntax error in the template.php file I get a warning, so I believe I am editing the right file. However, I don't think it loads that specific function at all (I tried "return drupal_render ($form['attachments']); " just to see if it would truncate the form and nothing happened).
A solution
I have installed the itweak module (http://drupal.org/project/itweak_upload) which does what I needed.
Interestingly after that the phptemplate_node_form ($node) function in template.php started to work! I needed it to collapse the upload path section and now it works. There must have been a conflict with some module I have.
FYI, here is my code for collapsing the upload path section (I have path auto so it's not necessary to display it):
Don't understand - Want File Attach Fieldset Expanded by Default
Folks,
Sorry for the lack of understanding here. I've tried the snippets of code here in my drupal install and it doesn't work. There is either no action or I get a white screen.
Can someone help out with some details on how I accomplish this. Here is my config:
Drupal 6.14
Access to update.php Protected
CAPTCHA Already 6 blocked form submissions
Configuration file Protected
Cron maintenance tasks Last run 8 min 52 sec ago
You can run cron manually.
Database updates Up to date
File system Writable (public download method)
GD library bundled (2.0.34 compatible)
Image import Import directory /var/www/html/tmp exists.
Image module directories Exists (sites/default/files/images).
Image toolkit The gd toolkit is installed.
MySQL database 5.0.84
MySQL database for event module 5.0.84
PHP 5.2.9
PHP memory limit 64M
PHP register globals Disabled
Unicode library PHP Mbstring Extension
Web server Apache/2.2.11 (Fedora)
================
Northern Computer Service, LLC
P.O. Box 1367
Woodruff, WI 54568
715.892.0530
715.358.9806
info@ncswi.com
www.ncswi.com
I recommend you try out
I recommend you try out iTweak Upload module. All you do is install it and it will immediately give you a prettier upload form which is also NOT collapsed. So give it a try if coding is giving you a hard time.
Just a certain node type
Using iTweak, how can I set expanding the file field set for only a particular node?
You should ask that in the
You should ask that in the iTweak issue queue.
You probably need to flush
You probably need to flush the theme registry to have the code active after you add it to your template.
Hal Eagar
Software Architect
hal.eagar@door3.com