Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Regarding the CVS message of Fieldgroup module (now part of 4.7.x-dev), September 5, 2006:
now a fieldgroup is hidden, if all its fields are hidden.
Shall we understand that is actually possible to hide CCK fields? If yes, how?
thanks
Comments
Comment #1
KarenS CreditAttribution: KarenS commentedAt the moment, this can only be done with a custom module using hook_form_alter(). Perhaps someone will propose another way (a new widget or an extension of some current widget).
So I guess I will make this a feature request since I don't think it is already proposed.
Comment #2
marcoBauli CreditAttribution: marcoBauli commentedThanks
also an alternative less techie way to do this is using the form_markup.module to assign a CSS
<div id="hidden">
class to the fields to hide, and hide them in the style.css (display:none;
).Comment #3
fagoyou are right, currently hook_form_alter() has to be used to hide fields.
Comment #4
marcoBauli CreditAttribution: marcoBauli commenteduhm.. could anyone be so kind to post an example of this using hook_form_alter() for most of us mortals? :)
Comment #5
chelahmy CreditAttribution: chelahmy commentedI've made a patch for 5.x-1.2 to hide any field. I'm not sure whether it will apply to the earlier versions. With this feature I don't need to theme a node just to hide the default field listing when I use dript.
The hidden attribute is similar to the required attribute. A new column 'hidden' is added in the node_field table so update.php need to be applied. I do not remove any hidden field from cck processing. However in the function theme_field() I make it return an empty string when a field is flagged as hidden.
Similar to the required field, I notice that all nodes type that share a field will also share the required and hidden attributes. There is no way two nodes with an identical field will be allowed to set the required and hidden attributes of the individual fields separately.
Field will not be made hidden automatically in custom theme. For theme writer, always check the field's hidden attribute. We can still manipulate hidden fields in the background, or we can force to display hidden fields anyway.
The patch involves three files: content.install, content.module, and content_admin.inc. I tried to attach the diff files here but it could take only one file. It doesn't accept zip.
Patch in content.install:
A column 'hidden' need to be added in table node_field. I added an update instruction with sequence number 1002 (its the next number in my copy).
Patch in content.module:
Force theme_field() function not to process hidden field.
Before
After
Patch in content_admin.inc #1:
Add the 'hidden' check box in field administration form.
Before
After
Patch in content_admin.inc #2:
Update a field hidden status in the database.
Before
After
Comment #6
yched CreditAttribution: yched commentedchelah : this thread is about hiding fields and fieldsets in the edit / creation form, whereas your patch deals with field display.
Besides latest cck 1.3 release now has an advanced field display page, that allows you to choose the displayed fields on teaser / full page view.
Comment #7
chelahmy CreditAttribution: chelahmy commentedIt's great if cck 1.3 have the feature I'm looking for. I'd been searching cck feature request list and found this thread with the same title of my problem. I've been following cck and had no idea when 1.3 will realease and will it include hiding a field. So I just went through the code and found an answer to my problem. Well, I'm thinking to contribute it back. Anyway, I'll be glad if anybody can move the post to a proper thread.
Comment #8
edrex CreditAttribution: edrex commentedcck 1.3 has field hiding