$type->has_title = $type->has_body = TRUE;

WTF?? In the form, we take care to honor these settings and here we destroy them?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

Status: Needs review » Reviewed & tested by the community

Same problem here, particularly with CCK types that should have no body which have 'has_body' reset to true every time you edit the content type. This patch fixes the problem and I think it is RTBC.

Dries’s picture

Why is this critical? How to reproduce this? (Would be great if Neil could take a look at this -- he might have authored that piece of code. Not sure.)

chx’s picture

Erm, this is likely written by *blush* me (or Jaza) as we have written most of the preCCK patch.

How to repro? Not too easy, I admit. Maybe create a node type, and in the database change its has_ttle attribute. Or check out CCK , patch it up so it runs more or less with D5... well, this is critical because as Karen points out it breaks CCK.

KarenS’s picture

To reproduce this, manually set has_body to false on a content type (which is what cck is going to do when it passes in content types created in 4.7). Then edit the content type and has_body will get reset to true.

This is complicated by the fact that there is no way to set has_body to turn it off when creating a new type, which will also be needed for the 5.0 port of CCK, but I didn't want to pollute this issue with another one. I'll need to create another issue for this.

I personally don't care about has_title, but the point of the patch is that it is arbitrarily resetting values, and I can't see any reason why it should do that.

KarenS’s picture

Status: Reviewed & tested by the community » Needs work

Now that I think about it, I have a more comprehensive solution to propose.

CCK does not use the body field and the node_types table has a value has_body which can be set to false, but the form has no way to indicate that you want no body in the type you are creating/editing, plus it makes the body label field a required field. The form needs to be altered to allow for types with no body. It could be done by making the body label a non-required field, adding in a description which says if the label is empty no body will be provided, and then changing the submit code to update the value in the node_types table appropriately (set has_body to false if there is no label, otherwise to true).

The submit code also needs to remove the item which forces that value to TRUE, as this patch does.

I don't have time to make a patch right now, but will try to get back to this later if no one else does.

KarenS’s picture

Status: Needs work » Needs review
FileSize
1.84 KB

Actually, chx's patch handled the submit part fine, but we need to make the fields not required and add some explanatory text, so here is a re-rolled patch with those two items.

drumm’s picture

I'm okay with body. Leaving that out can make sense in some cases and doesn't cause any real problems I can think of.

Title is a bit trickier. I do think that there are valid (but how often?) cases for it. However, the content administration page and other places assumes titles will exist. Maybe do just enough so that strange things can be done with titles using hook_form_alter() (or other appropriate API), but not with vanilla core?

drumm’s picture

Status: Needs review » Needs work
greggles’s picture

@drumm - in response to your question in #7 requesting the ability to remove the title from the form and replace it with default text, I believe the auto_nodetitle module does that http://drupal.org/project/auto_nodetitle

Is that what you were looking for? I'm assuming that module could be easily upgraded and work in 5.x. In that case this could be RTBC.

drumm’s picture

Great, that module can handle doing the necessary form alterations to set up the titles. Core needs to stay as functional as possible with every configuration possibility, so that means titles are required in Drupal core without any modules.

greggles’s picture

So, I apparently don't understand this issue well enough. My apologies.

KarenS’s picture

I'm fine with making the title required so long as the body is not. I am not where I can re-roll the patch right now, though. If no one else does it, I'll try to get back and do it later.

chx’s picture

Status: Needs work » Needs review

We removed mandatory title at least one (maybe two?) release ago. I am using a non titled node, it works flawlessly. This is a 'singleton' node, noone has the create rights for this nodetype and nodeadmins know better than to create another and there is a menu item pointing to it. The content admin screen also works, you can't click on the title, for there is no link but oh well, it's in the menu anyways. There is a use case which does not use anything but core and has no title. Do not take flexibility away.

drumm’s picture

The ability to have non-titled node types has been in the API, but never implemented in core itself. As chx mentions, there are some hoops to jump through, like creating a menu item and educating administrators, if you do have non-titled content types. I do think non-titled node types should be possible, as they were previously.

Attached is a patch which gives full control of the body field's existence, with less code. It keeps nodes with title fields having title fields, prevents node types without title fields from acquiring a title field, and doesn't get in the way of any module which modifies the form and this behavior. It fixes a undefined array issue when there isn't a title or body field.

drumm’s picture

FileSize
3.15 KB
drumm’s picture

FileSize
3.21 KB

chx pointed out that I might want to make that field non-required when disabled.

Jaza’s picture

Sorry, I think it's me that was responsible for the $type->has_title = $type->has_body = TRUE; line of code. IIRC, I put it in so that title and body would always be forced to be present for user-defined node types. For module-defined node types, this code isn't meant to kick in. But I guess that in the case of CCK node types, they end up being halfway between user-defined and module-defined, and this code ends up stopping them from being as flexible as they should be.

What should we be testing this patch with? Core CVS + CCK CVS?

KarenS’s picture

This works fine for me. I tested by manually changing a content type to have zero values for has_title and has_body, and then tried to edit the type and make sure those types did not get reset, and they did not (previously they did).

One minor nit, we lost the description for the title field if the field is editable.

drumm’s picture

I decided that "The label for the title field of this content type." wasn't adding much explanation since the label is "Title field label."

drumm’s picture

This is for testing on CVS core only. I haven't checked in with CCK contrib lately and don't know how ready it would be to test with CVS.

KarenS’s picture

CCK should work fine with cvs now.

KarenS’s picture

Status: Needs review » Reviewed & tested by the community

In addition to testing it by manually changing the content type, I have now tested it with latest cvs of Drupal and CCK and it seems to work fine. I think it's RTBC.

amitaibu’s picture

As seen here - it is also important for us the CCK users :)

mcreature’s picture

+1 to get this commited

drumm’s picture

For the record, I'm not committing this since I wrote the last version, which I think is ready to go.

dodorama’s picture

+1 to get this committed. CCK users can't live without it.

chx’s picture

Version: x.y.z » 5.0-beta1

Dries? Steven?

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed! Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)