Hello,

A colleague of mine, working on a custom CCK field ran into some issues today. His field type could be added to a content type, bout wouldn't show up in either the admin 'display fields' or on the node edit form. It would however, strangely enough, appear on the admin 'display fields' form.

His widget name as defined in the hook_widget_info function was 'BAM_organisationfield_autocomplete'.

I dug a bit deeper and found the root of the problem to be connected to line 619 in the content.module ()

$module = $widget_types[$field['widget']['type']]['module'];

Upon printing out some debug data I found out that the content module was looking for

$field['widget']['type'] = "BAM_organisationfield_autocomple" rather than "BAM_organisationfield_autocomplete".

That's when I realised it was probably related to how the field was stored in the database and yes indeed, the widget_type field is a varchar(32).

I shortened the widget name (and changed the values in the db manually) and everything works fine now.

Maybe the documentation should make mention of the fact that widget names can be max 32 characters ?

Cheerio,
Wouter

Comments

KarenS’s picture

Hard to believe this hasn't come up before now, now that I see the issue, I think the potential for this has always been in the code. Definitely a bug, I'll work on a fix.

KarenS’s picture

Status: Active » Fixed

Committed a fix to all branches to limit the internal field and widget names to 32 characters, and to add documentation to field.php indicating that field and widget names are truncated at 32 characters.

yched’s picture

is truncating the right solution ? What happens if truncating causes name clashes ? Wouldn't we be better off extending the db columns length ?

KarenS’s picture

We have to truncate the values to some length, the problem is that when we read the field name from the field table it has a fixed length, but when we get it by invoking field_info() there is no check that the field or widget names are the same size, leading to possible mis-matches between the field name we get from invoking and from reading the file. So no matter what we do, we need to be sure our internal names are no longer than whatever we store in the database by truncating them to the database length.

Since nothing has been reported about this before, I'm guessing it hasn't become a problem yet and we're just keeping it from turning into a problem, so the current length may be fine.

We already have problems with the size of CCK queries with all the long field and table names, so if we can live with 32 characters, I think we should leave it there.

yched’s picture

OK, makes sense :-)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.